Tsahi Deri
Tsahi Deri

Reputation: 581

UIWebView - Set default date programmatically

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

Answers (1)

Sarath Kumar
Sarath Kumar

Reputation: 2353

try this in javascript ..

    document.getElementById("startDate").valueAsDate = new Date();

Upvotes: 3

Related Questions