Anidh Singh
Anidh Singh

Reputation: 324

Input type date with specific format

I am designing a HTML form where i have to take date in "DD/MM/YY" or "DD/MM/YYYY" format and i have to achieve this task using only HTML date control. I have done extensive research and haven't found any way to do it. Can someone help me.

Upvotes: 1

Views: 6653

Answers (2)

Suriya Subramaniyan
Suriya Subramaniyan

Reputation: 137

<form method="POST" action="">
<input type="text" pattern="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d" required />
<button>ok</button>
</form>

Use regular expression like patterns.Refer HTML5 pattern, Docs, http://html5pattern.com/Dates

Upvotes: 0

Naveen Sharma
Naveen Sharma

Reputation: 11

Refer this link: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date Or you can use jquery date picker also for this.datepicker is very easy to use.

Upvotes: 1

Related Questions