Reputation: 2074
I have an input where I want to test if the inserted text is only in Arabic characters as following :
ng-pattern="/^([\u0600-\u06ff]|[\u0750-\u077f]|[\ufb50-\ufbc1]|[\ufbd3-\ufd3f]|[\ufd50-\ufd8f]|[\ufd92-\ufdc7]|[\ufe70-\ufefc]|[\ufdf0-\ufdfd]|[ ])*$/g"
this input works and accepts only Arabic values but it only accepts values that have a length of an odd number, for example when I type : عماد
which has 4 characters it wont work but when I type : أسماء
which has 5 characters it works.
this is my jsfiddle :
so why do I get this behavior ?
Upvotes: 0
Views: 423
Reputation: 1694
Use following pattern:
ng-pattern="/^[\u0621-\u064A\u0660-\u0669 ]+$/"
For detail, have a look at Regular Expression Arabic characters and numbers only
Upvotes: 1