1
<input type="date" name="logdate" id="logdate" value="11/15/2013" />

This is the HTML I'm using for a date field in Jquery mobile.

It's always blank on my iPhone with iOS7 with Safari.

Also always blank on my Android with Chrome

Populates as expected in Firefox, Chrome, etc. desktop

Is it possible to set the default value of a data field in jQuery mobile?

jQuery Mobile 1.3.2 jQuery 1.9.1

I've found around a half dozen articles suggesting javascript, etc. but none work and it seems like the "value" attribute should tag care of this.

Like this... this did not work:

How to set default current date using jquery mobile?

It works when you run it via jsFiddle on a desktop browser but not on the mobile browsers I have at my disposal.

1 Answer 1

3

This could a side effect of the HTML5 input type of date not being fully supported on all browsers yet. To check this see the CanIUse.com section for input of type date.

Another thing to look at is how you are trying to set the value of the date. According to the documentation the date must be in the format YYYY-MM-DD.

Sign up to request clarification or add additional context in comments.

1 Comment

[code]<input type="date" name="logdate" id="logdate" value="<?= date("Y-m-d", time()) ?>"/>[/code] I used this based on your suggestion and it worked. I had been trying to use javascript to set the default but doing this using PHP worked. Did not test, but imagine the key is using the format you suggest and it would likely work in Javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.