I see there are some similar questions to this, but none solve my issue.
I am working on an MVC3 app with Entity Framework 4.3. I have a UK date field that i plan t
Actually I have found a better solution here.... by #fretje
Override jquery date
I have modified his/her code slightly though so that it can still take date formats like 30 May 2012 below.
$(function () {
$.validator.addMethod(
"date",
function (value, element) {
//Added to validate dates like 31 May 2012
if (value.split('/').length === 1)
return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
var bits = value.match(/([0-9]+)/gi), str;
if (!bits)
return this.optional(element) || false;
str = bits[1] + '/' + bits[0] + '/' + bits[2];
return this.optional(element) || !/Invalid|NaN/.test(new Date(str));
},
"Please enter a date in the format dd/mm/yyyy"
);
$global.init();
});