Regular Expression for arabic numbers

2019-03-19 12:44发布

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 ??

3条回答
ゆ 、 Hurt°
2楼-- · 2019-03-19 13:10

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

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

查看更多
看我几分像从前
3楼-- · 2019-03-19 13:15

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"); 
查看更多
啃猪蹄的小仙女
4楼-- · 2019-03-19 13:16

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

查看更多
登录 后发表回答