How to validate date on JQuery datepicker?

Hi there

this is my jsfiddle.net
http://jsfiddle.net/vngx/099qnwkb/

What I want if someone has select date more than Today then it should error.
Date less that today are acceptable but not date after Today

How can I acheive this?

Thanks

if you’re using the datepicker, use the max date option. This one sets the max date to yesterday.

https://api.jqueryui.com/datepicker/#option-constrainInput

 $(function() {
$("#select_date").datepicker({
  maxDate: "-1d"
});
})
1 Like
$(function() {
 $("#select_date").datepicker();
 $("#select_date").on('change', function(){
     
         var date = Date.parse($(this).val());

         if (date > Date.now()){
             alert('Please select another date');
             $(this).val('');
         }
     
    });
});

@megazoid:

COOL!!!

As usual
Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.