Jquery validate form with date

I am using the jquery validate function for a bootstrap form with a date but at the moment the user can amend the date to a date in the past (which I want to prevent). Can anyone tell me if this can be done?

You can create a custom validation rule with jquery validate. In your case, you want to have future dates only:

jQuery.validator.addMethod("future", function(value, element) { 
    return this.optional(element) || Date.parse(value) < new Date().getTime(); //use Date.now() if you can instead of getTime, it's nicer
}, "Please enter only future dates");

Then you can add “future” as a validation rule just like required, email, etc.

Thank you for your reply. It was really helpful. I had looked at the documentation online but didn’t realise adding a custom validation rule was this easy :smile: