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.
Try this pattern
/^([A-Za-z]+)$/
Right now you are saying that you want one character anywhere in the string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.