Created
September 19, 2012 08:08
-
-
Save martinnormark/3748326 to your computer and use it in GitHub Desktop.
Bridge jQuery Validate with Globalize, to ensure correct validation for different cultures.
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
// Override jQuery Validate methods to be aware of different cultures. | |
// This will use Globalize (https://github.com/jquery/globalize) methods. | |
$.validator.methods.number = function (value, element) { | |
return this.optional(element) || !isNaN(Globalize.parseFloat(value)); | |
}; | |
$.validator.methods.range = function (value, element, param) { | |
value = Globalize.parseFloat(value); | |
return this.optional(element) || (value >= param[0] && value <= param[1]); | |
}; | |
$.validator.methods.min = function (value, element, param) { | |
value = Globalize.parseFloat(value); | |
return this.optional(element) || value >= param; | |
}; | |
$.validator.methods.max = function (value, element, param) { | |
value = Globalize.parseFloat(value); | |
return this.optional(element) || value <= param; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment