0

I have an input field as follows:

<input type="Date" id="datepicker">

Now I want to validate this field such that the user can't select a date after the system's date and also can't select a date before a date specified.

For example, if today's date is, 01-Oct-2015, then the user can't select any date after 01-Oct-2015 and also he/she can't select any date before, let's say, 02-Jan-2013.

How to do this using JavaScript?

ArpanMona
  • 47
  • 1
  • 7
  • 2
    Which plugin are you using? Some plugin has option to do the validation. Otherwise there are a few ways you can do the validation, upon the user select the date or upon user submit the form, which alert the user that it is an invalid date. – iCezz Oct 10 '15 at 04:10
  • Any example code that you try and did not work ? Possible duplicates of http://stackoverflow.com/questions/29544746/validate-a-condition-in-html-form-using-javascript/29545851#29545851 http://stackoverflow.com/questions/16199717/select-box-date-validation-in-javascript http://stackoverflow.com/questions/6272878/date-validation-in-javascript – prasun Oct 10 '15 at 04:34
  • Possible duplicate of [Date validation through javascript](http://stackoverflow.com/questions/838983/date-validation-through-javascript) – prasun Oct 10 '15 at 04:36

0 Answers0