Created
November 8, 2013 15:19
-
-
Save AngeloMerlo/7372485 to your computer and use it in GitHub Desktop.
Arruma erro de validação do datepicker no chrome.
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
$(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