I have a form text field that has a KeyUp event. On KeyUp I\'m ignoring anthing but numbers, the period, backspace, delete and cursor keys. So, the only thing in the field ca
try this expression: the 100% is a special case of a more generic pattern
var re = /^((0|[1-9]\d?)(\.\d{1,2})?|100(\.00?)?)$/;
explanation
(0|[1-9]\d?) allows numbers from 0 to 99
(\.\d{1,2})? allows a dot with 1 or 2 digits after
| otherwise
100 accept 100
(\.00?)? with optional 0 or 00
Edit:
I tried this jsfiddle demo http://jsfiddle.net/pCDVn/1/ and it's working... look at the console