Last active
December 27, 2015 16:29
-
-
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
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
// 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