如何验证必须为10位数的手机号码。不超过10且不低于10? [英] how do I validate mobile number that must be 10 digits. No more than 10 and no less than 10?

查看:106
本文介绍了如何验证必须为10位数的手机号码。不超过10且不低于10?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何验证asp.net中的手机号码?

解决方案

再次,我会问我的朋友Google [ ^ ]。


请参阅我的评论问题。

学习正则表达式:

https://msdn.microsoft.com/en-us/library/hs600312.aspx [ ^ ],

https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex%28v=vs.110%29.aspx [ ^ ],

http://en.wikipedia.org/wiki/Regular_expression [ ^ ],

http:/ /www.regular-expressions.info/reference.html [ ^ ]。



-SA


试试这段代码:



 <   asp:TextBox     ID   = < span class =code-keyword> TextBox1    runat   = 服务器 >   <   / asp:TextBox  >   <   br \  >  
< asp:RegularExpressionValidator ID = RegularExpressionValidator1 runat = server

ControlToValidate = TextBox1 ErrorMessage = RegularExpressionValidator

ValidationExpression = [0-9] {10} > < / asp:RegularExpressionValidator >


how to validate mobile number in asp.net??

解决方案

Again, and again, I would ask my friend Google[^].


Please see my comment to the question.
Just learn Regular Expressions:
https://msdn.microsoft.com/en-us/library/hs600312.aspx[^],
https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex%28v=vs.110%29.aspx[^],
http://en.wikipedia.org/wiki/Regular_expression[^],
http://www.regular-expressions.info/reference.html[^].

—SA


Try this code:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br\>
    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"

      ControlToValidate="TextBox1" ErrorMessage="RegularExpressionValidator"

    ValidationExpression="[0-9]{10}"></asp:RegularExpressionValidator>


这篇关于如何验证必须为10位数的手机号码。不超过10且不低于10?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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