15

I have this form that has a validation JQuery function, I have a problem with the telephone field, all I want is for the users to enter numbers only ... Its working great on the English form, but on the Arabic form, if I enter the numbers using the Arabic language the form won't submit. Anyone knows what is the regular expression for the Arabic numbers ??

MrSmith42
  • 9,961
  • 6
  • 38
  • 49
Naruto
  • 6,398
  • 5
  • 21
  • 24
  • 3
    I always thought the numbers we are using in in the western culture ARE Arabic ... – Hinek Nov 09 '10 at 13:22
  • 2
    @Hinek there are east arabic numerals which are different. I learned that in another question here on SO... – Pekka Nov 09 '10 at 13:22
  • Can you give examples of valid and invalid numbers with reasoning? – Brad Nov 09 '10 at 13:25
  • Arabic numbers are exactly equivalent to ordinary numerals, except for the different charset (but it is a bit hard to distinguish 0 from a dot). – Ofir Nov 09 '10 at 13:29
  • 1
    @Hinek background info http://en.wikipedia.org/wiki/Eastern_Arabic_numerals – Pekka Nov 09 '10 at 13:39
  • In the link Pekka sent, the Arabic numbers work perfectly fine, but when anyone enters any of the Indian numerals I get the message from the validation function that says, user is allowed to enter numbers only ... – Naruto Nov 10 '10 at 07:16
  • Does this answer your question? [Regular Expression Arabic characters and numbers only](https://stackoverflow.com/questions/29729391/regular-expression-arabic-characters-and-numbers-only) – Liam Mar 18 '22 at 16:54

3 Answers3

23

Try this one:

/[\u0660-\u0669]/

Example:

var arNumbers = '٠١٢٣٤٥٦٧٨٩'
    ,reg_arNumbers = /^[\u0660-\u0669]{10}$/;

if (reg_arNumbers.test(arNumbers))
     alert("10 Arabic Numerals");
else
     alert("Non-Arabic Numerals"); 
Layal - ليال
  • 908
  • 6
  • 13
2

You can use [^[:digit:]].

This will return any digit no matter which language including mixed languages

OhadM
  • 4,687
  • 1
  • 47
  • 57
0

This is likely the result of unicode vs. ASCII - the regular expression should be trivial otherwise.

Ofir
  • 8,194
  • 2
  • 29
  • 44