Validation of the date using jquery, prevents yesterday's date input.


I am trying to validate a date input field. I can prevent jquery datepicker to prevent from entering old dates using,

 $('#delivery_date').datePicker({ minDate: 0 });

But user can still enter date manually. How to prevent or validate this?

// when the field changes value
    var today = new Date();
    today = new Date(today.getYear(), today.getMonth(), today.getDate());
    // compare the value of the field with whatever you want to test against
    if($(this).val() > today){
         // if the test fails, change the value to default
         $(this).datepicker('setDate', new Date());