Reputation: 581
I'm trying to display default date in input embedded in iOS UIWebview :
<input type="date" id="startDate" format="dd/mm/yyyy" />
by using this javascript code :
var myDate = new Date();
document.getElementById("startDate").value = myDate.getDate()+1.0 + "/" + (myDate.getMonth() * 1.0 + 1.0 * 1.0) + "/" + myDate.getFullYear();
The date appears only after I choose a date from the native date picker. How can I set the default date programmatically ?
Upvotes: 3
Views: 349
Reputation: 2353
try this in javascript ..
document.getElementById("startDate").valueAsDate = new Date();
Upvotes: 3