Aravind Bharathy Aravind Bharathy - 8 months ago 31
Javascript Question

Limiting date range in HTML 5

I have a input field with type date

<input type="date" id="datepick" name="mybirthday" placeholder="Birthdate(MM/DD/YYYY)" />

Here I want to limit the date range that the user can choose. To be more specific, I dont want the user to choose a birthdate like 22/08/2015. How can I do this?


Use the min and max attributes:

<label>Enter a date before 1989-10-30:</label>
<input type="date" name="myDate" max="1989-10-29">

<label>Enter a date after 2001-01-01:</label>
<input type="date" name="myDate" min="2001-01-02">