Skip to content

Instantly share code, notes, and snippets.

@AngeloMerlo
Created November 8, 2013 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AngeloMerlo/7372485 to your computer and use it in GitHub Desktop.
Save AngeloMerlo/7372485 to your computer and use it in GitHub Desktop.
Arruma erro de validação do datepicker no chrome.
$(document).ready(function(){
// fix date validation for chrome
jQuery.extend(jQuery.validator.methods, {
date: function (value, element) {
var isChrome = window.chrome;
// make correction for chrome
if (isChrome) {
var d = new Date();
return this.optional(element) ||
!/Invalid|NaN/.test(new Date(d.toLocaleDateString(value)));
}
// leave default behavior
else {
return this.optional(element) ||
!/Invalid|NaN/.test(new Date(value));
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment