Skip to content

Instantly share code, notes, and snippets.

@igorescobar
Last active December 27, 2015 16:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igorescobar/7355657 to your computer and use it in GitHub Desktop.
Save igorescobar/7355657 to your computer and use it in GitHub Desktop.
This mask validates if the typed number is hight than 10.00 and lower than 100.00
// http://jsfiddle.net/cKz5u/9/
var handleValidNumber = function (triggerValidation, el) {
var n = el.val(), arNumber = n.split(''),
isInValid = function(number) {
number = parseFloat(number, 2);
return number < 10.00 || number > 100.00;
};
if (n.length >= triggerValidation && isInValid(n)) {
while (isInValid(el.val()) && el.val().length > 0) {
arNumber.pop();
el.val(arNumber.join(''));
el.keyup();
}
}
}
$("#number").mask("000.00", {
onKeyPress: function(n, e, f, o) {
handleValidNumber(5, f);
}, reverse: true
}).blur(function() {
handleValidNumber(1, $(this));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment