Regex for persian number

后端 未结 2 1294
旧巷少年郎
旧巷少年郎 2020-12-11 20:10

I want to create javascript Regex for checking value of textbox in range \"U+06F0 and U+06F9\" or \"0-9\" How can I build this?

2条回答
  •  自闭症患者
    2020-12-11 20:51

    You can test the regex pattern on regexr.com and then use it in your code. I use to match the persian mobile number with unicode in blew: <\u06F0 to \u06F9> equal to <۰-۹> that matches persian number like this "۰۹۱۹۹۱۹۱۱۲۲".

        $("#registerForm").validate({
            rules:{
                mobile:{
                    required:true,
                    pattern : /^[\u06F0][\u06F0-\u06F9]{3}[\u06F0-\u06F9]{3}[\u06F0-\u06F9]{4}/,
    
                },
            },
            messages:{
                mobile:{
                    required:"شماره تلفن همراه خود را وارد کنید",
                    number:"فقط عدد وارد کنید",
                    pattern:"تلفن همراه را به درستی وارد کنید"
                },
            },
            errorClass: "help-inline",
            errorElement: "span",
    
        });
    

提交回复
热议问题