验证文本框的电话号码 [英] Validate textbox phonenumber
问题描述
我想在提交表单之前验证移动应用程序的电话号码..我怎么能?
我试过以下代码,但它允许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屋!