Hi everyone I'm trying to manually assign a value to an html date input field. But it doesn't work.
First I tried to pass the value the way I do it for ordinary input box
<?php $newDate2 = '03/31/2014'; ?>
<form name='RegForm' method='GET'>
<input type="date" name="sdate" id="sdate" value="<?php echo $newDate2; ?>" required>
</form>
When It didn't work I tried to Use Javascript width something like this:
<head>
<script type="text/javascript">
function showInvoiceDate(){
var mYDate = new Date('2011-04-11');
alert(mYDate);
document.getElementById("sdate").value=mYDate;
}
</script>
</head>
<body onload="showInvoiceDate();">
<form name='RegForm' method='GET'>
<input type="date" name="sdate" id="sdate" required>
</form>
</body>
The function is being prompted. Because Alert box shows the value of myDate
But the value of date box is not being changet its still mm/dd/yyy
So What am I doing wrong?