Reputation: 653
I have a problem about regex expression in Angular/Javascirpt.
I have a regex expression as below. This is work for limit 0-100.
But how to limit the input is not blank ? For example user type something text in the input textfield, then user press the delete or backspace key to empty the textfield, the regex work !
ng-pattern="/^[0-9][0-9]?$|^100$/"
I already put the regex in this.
Upvotes: 0
Views: 873
Reputation: 835
You can use the following pattern:
^(?:[1-9]?\d|100)$
It will allow 100
and other number below, but not numbers starting with 0
such as 01
. Blank is also not matched but 0
alone is.
Upvotes: 1