2

I have a input tag like this:

<input class="span2" type="date" name="date" value="01/12/2012">

The input form in template is displayed like mm/dd/yyyy. The static value that I provided is not working. However when I change the type to date it works. Does html not allow this?

1
  • What are you trying to show? Commented Mar 23, 2013 at 5:02

2 Answers 2

7

The input tag with type="date" is supposed to accept dates in the format of YYYY-MM-DD and not mm/dd/yyyy as you are trying to pass.

Read more about it on w3.org and validity is defined as per RFC 3339.


Therefore, the value should be passed as

value="2012-01-12"
Sign up to request clarification or add additional context in comments.

1 Comment

Damn, beat me by 10 seconds!
3

You're not conforming the HTML5 specification: http://www.w3.org/TR/html5/forms.html#input-author-notes

The specification requires that all literal date values be written in ISO 8601 format: yyyy-MM-dd:

The format used "on the wire", i.e. in HTML markup and in form submissions, is intended to be computer-readable and consistent irrespective of the user's locale. Dates, for instance, are always written in the format "YYYY-MM-DD", as in "2003-02-01". Users are not expected to ever see this format.

Comments

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.