Reputation: 223
I'm using Angular's form validation with ng-pattern
to validate a username with Special Charter
ng-pattern="/^[a-z]+@+[a-z]*$/"
My problem is that is limited to only one type of Special Charter to be placed at required place.
I would like this to support any of the special characters we use in alphabets
Upvotes: 4
Views: 8989
Reputation: 53
/^[a-zA-Z0-9/""\\\]\[:;|=,+*?<>]+$/
allows: characters, digits and " / \ [ ] : ; | = , + * ? <>
Upvotes: 0
Reputation: 34257
It's not clear of what you define a Special Character, therefore assuming by your example that @
is a Special Character.
For example, if you want to support the characters @
, !
and #
, you will modify the regular expression like this:
ng-pattern="/^[a-z]+[@+!+#][a-z]*$/"
demo: http://plnkr.co/edit/cIjpI9LAJKgs1MvZmBJv?p=preview
Upvotes: 1