I am working on a simple PHP website where the user has to enter data in a form,
and if the user didn't enter Arabic letters I want to show a warning message "Arabic only" , I tried using the code below but it shows the warning message if I entered both Arabic or English letters.
Answer
In your example, you need to create a RegEx object to test against.
var isArabic = /[\u0600-\u06FF\u0750-\u077F]/;
if (isArabic.test(x)){
...
}
There's no coercion from a string to a regular expression in JavaScript.
No comments:
Post a Comment