Validation on text on alphabets enter Validation on text on alphabets enter angularjs angularjs

Validation on text on alphabets enter


Depending on what you want:

Alphabets and blankspace:

ng-pattern="/^[a-zA-Z\s]*$/"

Alphabets no blankspace:

ng-pattern="/^[a-zA-Z]*$/"


I guess all the other answers using ng-pattern are correct but just to mention, the use of ng-model is compulsory with ng-pattern.

The complete input can be:

 <input type="text" ng-pattern ="/^[a-zA-Z\s]*$/" ng-model="Name" />

This will accept the alphabets and the spaces only.


add this to your input

ng-pattern="/^[a-zA-Z]$/"