Forum Moderators: open
One possible solution might be something like ...
function lessThanOneHundred(element)
{
var re = /^\d{0,2}(\.\d{0,2})?$/
if (element.value &&!re.test(element.value)) {
alert('The value must be < 100 with only 2 decimal places.')
element.focus()
element.select()
return false
}
return true
}
// Match 0-3 digits: \d{0,3}
// at the start of the string: ^\d{0,3}
// followed by:
// a decimal followed by 0-2 characters at the end of the string: \.\d{0,2}$
// OR
// the end of the string: $
var reg = /^\d{0,3}(\.\d{0,2}$¦$)/;
var val = "100.00";
var result = reg.test(val);
alert(result);
However, this only checks the number of digits. You'll still need to check the value separately to see if it's greater than 100.00.