Created
July 17, 2018 13:31
-
-
Save joeRinehart/0e8af523fdfc567cc670ddca2eaff137 to your computer and use it in GitHub Desktop.
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
/* | |
See https://github.com/jquery-validation/jquery-validation/issues/379. | |
The maintainors of jQuery validate are OK validating whether or not 1,000,000 and 1.000.000 are numbers, | |
but aren't getting into parsing their values (because of international formats), so the min, max, and range | |
rules don't support anything formatted. | |
*/ | |
$.validator.addMethod('min', function( value, element, param ) { | |
value = numeral(value).value(); | |
return this.optional(element) || value >= param; | |
}); | |
$.validator.addMethod('max', function( value, element, param ) { | |
value = numeral(value).value(); | |
return this.optional(element) || value <= param; | |
}); | |
$.validator.addMethod('range', function( value, element, param ) { | |
value = numeral(value).value(); | |
return this.optional(element) || ( value >= param[0] && value <= param[1] ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment