javascript - regex to validate three digit with one decimal -
i have written regex validate number containing 3 digits , 1 decimal return false in cases.
re = new regexp("^\d{1,3}\.*\d{0,1}$"); re.test(33.0);
i tried many combinations not working. aim validate number @ max 3 digit 1 decimal , less 100. can handle less 100 part.
this 1 want:
var test = [ 123, 12.34, 100.1, 100, 12, 1.2, 1 ]; console.log(test.map(function (a) { return a+' :'+/^(?:100(?:\.0)?|\d{1,2}(?:\.\d)?)$/.test(a); }));
Comments
Post a Comment