Reputation: 2711
I have some form fields where I only want to allow letters for them to be ('ng-valid'). I have it like the following:
<input type="text" ng-model="Example.field1" ng-pattern="/[a-zA-Z]/" />
It works correctly if you only type in letters, or only type in non-letters, but if they are mixed it won't mark the field as invalid. Can someone tell me why this would be happening? Thanks in advance.
Upvotes: 0
Views: 46
Reputation: 190925
Try this pattern
/^([A-Za-z]+)$/
Right now you are saying that you want one character anywhere in the string.
Upvotes: 1