I’ve found this useful bit of code that allows uk dates to work in Chrome but I’m not sure how to implement it. It overrides the default date functionality.
date: function(value, element) {
//ES - Chrome does not use the locale when new Date objects instantiated:
//return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
var d = new Date();
return this.optional(element) || !/Invalid|NaN/.test(new Date(d.toLocaleDateString(value)));
},
How can I add this into jQuery validate to override the default functionality.
Here is where I found the code sample
You should call the validator.addMethod method after loading the jquery.validate library like so:
Note that I used another way of actually validating the input, as the code in your question will not work (toLocaleDateString doesn’t take a parameter). You could also change this to use the datejs library as Mrchief pointed out in the comments.