How to update date in date picker??
--> Most important thing while updating date in date picker is Date Format. Date format should be like yyyy-mm-dd. If it is not then date picker will not accept it. so first it should be convert to it using toISOString() method.
<input type="date" id='mydate'>
<button onclick="setcurrentdate()">Set Today's Date</button>
<script>
function setcurrentdate()
{
var date = new Date();
var date1 = date.toISOString().substring(0,10)
document.getElementById("mydate").value = date1;
}
</script>
Comments
Post a Comment