Reference(source) site url : Click here
Tuesday, June 12, 2018
Monday, May 28, 2018
the field date must be a date in mvc
JQuery bootstrap date picker function in jquery.validate.js shows message 'the field date must be a date'. Override the validate date function from jquery.validate.js
Create jquery.validate.date.js and ensure it is loaded after jquery.validate.js
Reference from this link.
Add the following code to jquery.validate.date.js
$(function() {
$.validator.methods.date = function (value, element) {
if ($.browser.webkit) {
//ES - Chrome does not use the locale when new Date objects instantiated:
var d = new Date();
return this.optional(element) || !/Invalid|NaN/.test(new Date(d.toLocaleDateString(value)));
}
else {
return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
}
};
});
Create jquery.validate.date.js and ensure it is loaded after jquery.validate.js
Reference from this link.
Add the following code to jquery.validate.date.js
$(function() {
$.validator.methods.date = function (value, element) {
if ($.browser.webkit) {
//ES - Chrome does not use the locale when new Date objects instantiated:
var d = new Date();
return this.optional(element) || !/Invalid|NaN/.test(new Date(d.toLocaleDateString(value)));
}
else {
return this.optional(element) || !/Invalid|NaN/.test(new Date(value));
}
};
});
Subscribe to:
Posts (Atom)
