Last active
February 9, 2019 08:09
-
-
Save jeremypage/1367702fb21e5aebd1797127a31721f7 to your computer and use it in GitHub Desktop.
jQuery Validate: Custom unobtrusive date validator (fixes Chrome date validation bug)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Handle Chrome date validation 'bug' | |
jQuery.validator.addMethod('date', function (value, element) { | |
jQuery.culture = Globalize.culture("en-GB"); | |
var date = Globalize.parseDate(value, "dd/MM/yyyy", "en-GB"); | |
return this.optional(element) || !/Invalid|NaN/.test(new Date(date).toString()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment