Last active
January 28, 2019 14:52
-
-
Save devsuperman/a884cff9f792a017898a3ef4c78956f0 to your computer and use it in GitHub Desktop.
Método de extensão do jQuery para validar data e números em formato brasileiro
This file contains 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
//Substitui o ponto pela virgula ao validar inputs decimais. Muito adequado para inputs de valor monetário. | |
$.validator.methods.range = function (value, element, param) { | |
var globalizedValue = value.replace(",", "."); | |
return this.optional(element) || (globalizedValue >= param[0] && globalizedValue <= param[1]); | |
}; | |
$.validator.methods.number = function (value, element) { | |
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:[\s\.,]\d{3})+)(?:[\.,]\d+)?$/.test(value); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment