I am working on an application that requires a text field to only accept positive integers (no decimals, no negatives). The user should be restricted to entering values between 1 and 9999.
<input type="text" min="0" max="99" number-mask="">
While searching online, I came across this JSFiddle which unfortunately accepts negative integers and is not compatible with Internet Explorer.
I am relatively new to writing directives and currently learning Angular. I use TypeScript for generating Angular in my .NET MVC project.
Here is the code snippet:
var app = angular.module('myApp', []);
app.directive('numberMask', function() {
return {
restrict: 'A',
link: function(scope, element, attrs) {
$(element).numeric();
}
}
});
I am wondering if it's possible to add a check for negative numbers in the code. Something like:
if(element < 0 && element.length > 4)
.....
else
....
Thank you in advance!