I use https://github.com/AlphaGit/ng-pattern-restrict to limit input. What I'm trying to do is just the alphanumeric value for the first character ONLY. The problem is that I am using:
ng-pattern-restrict="^[a-zA-Z0-9]+"
it works, but will not allow the user to clear the entire line, which I will also like as an option.
Refresh the regex to check for an empty script. Example below:
^$|^[A-Za-z0-9]+
Plunker
This pattern allows at least one alphabet and one numeric value, but does not allow the creation of special characters.
ng-pattern="/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/"
This expression will help in clearing the input, and also does not allow the appearance of a character at the input in any position: ng-pattern-restrict="^$|^[A-Za-z0-9]+$"
ng-pattern-restrict="^$|^[A-Za-z0-9]+$"