验证文本框的电话号码 [英] Validate textbox phonenumber

查看:121
本文介绍了验证文本框的电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在提交表单之前验证移动应用程序的电话号码..我怎么能?



我试过以下代码,但它允许9999.99999 ,999999999 +,(maxlength为10)..



i want to validate phone number for mobile application, before submitting form.. how can i?

I have tried the following code,but it allows " 9999.99999","999999999+",(maxlength is 10)..

if (isNaN(mobile))
    // else if(num.test(mobile) == false)
    {
       alert("Invalid phone number");
        $( "#mphone" ).focus();
        $('#mphone').val("");

         return false;
    }







我的要求:它不应该允许数字之间的空格而且它不应该允许(。,+, - 在数字之间)。应该只允许号码9999999999



请帮帮我....




my requirement: it should not allow spaces between number and it should not allow(.,+,- between number). should allow only number 9999999999

Help me please....

推荐答案

#mphone)。focus();
( "#mphone" ).focus();


#mphone')。val( );

return false ;
}
('#mphone').val(""); return false; }







我的要求:它不应该允许数字之间的空格而且它不应该允许(。,+, - 在数字之间)。应该只允许号码9999999999



请帮帮我....




my requirement: it should not allow spaces between number and it should not allow(.,+,- between number). should allow only number 9999999999

Help me please....


当他们不知道时你会惹恼用户您想要的移动电话号码的正确格式。我只检查用户是否只输入了数字。



You tend to annoy users when they don't know the correct format you want for your mobile no. I only check that the user has entered only digits.

if (! /^\d+


这篇关于验证文本框的电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆