I'm using https://github.com/AlphaGit/ng-pattern-restrict to restrict input. What I"m trying to do is only allow alphanumeric for the first character ONLY. The problem is if I use :
ng-pattern-restrict="^[a-zA-Z0-9]+"
it works, but won't allow user to clear the whole string, which I would also like as an option.
Update your regex to check for the empty string scenario. Example below:
^$|^[A-Za-z0-9]+
Plunker
ng-pattern-restrict="^([A-Za-z0-9]{0,})$"
This will allow only alhpanumeric values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With