验证文本框的电话号码

编程入门 行业动态 更新时间:2024-10-17 16:27:48
本文介绍了验证文本框的电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在提交表单之前验证移动应用程序的电话号码..我怎么能? 我试过以下代码,但它允许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+

更多推荐

验证文本框的电话号码

本文发布于:2023-11-24 23:20:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627312.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文本框   电话号码

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!