Skip to content Skip to sidebar Skip to footer

Ng-pattern For Password Text To Accept All Special Characters And Numbers, Alphabets

Html
username

Solution 1:

Use the following ng-pattern:

ng-pattern="/^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@('@')$!%*#?&{}[\]<>()^+=;:'&quot;/\\|-])[A-Za-z\d$@('@')$!%*#?&{}[\]<>()^+=;:'&quot;/\\|-]{8,20}$/"

Note that \ and ] are escaped in the character class with \ and the double quotes are represented as a &quot; HTML entity. The hyphen does not need escaping when at the character class end.

See the updated plunkr.


Solution 2:

Escape special symbols by "\" char before each special symbol.


Post a Comment for "Ng-pattern For Password Text To Accept All Special Characters And Numbers, Alphabets"