Created
July 21, 2016 07:14
-
-
Save thomas479/056278b098f06eec16d4c112433e1e94 to your computer and use it in GitHub Desktop.
JQuery validator number extention. Allows both the decimal dot and decimal comma.
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
$.extend( $.validator.methods, { | |
number: function( value, element ) { | |
var result = false; | |
if(/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:,\d+)?$/.test( value )){ | |
result = true; | |
} else if(/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test( value )){ | |
result = true; | |
} | |
return this.optional( element ) || result; | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment