验证文本框仅输入5个数字 [英] validate textbox to enter only 5 numbers
本文介绍了验证文本框仅输入5个数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友们,
我的网页上有两个文本框
例如:
办公室电话号码:TEXTBOXOffTel
分机:TEXTBOX扩展
现在我的要求是 - 在TEXTBOXOfftel中,用户必须输入的数字不是字母,数字必须只有5位数。
和TEXTBOX分机用户必须输入的数字不是字母,数字必须只是4位数。
请帮助我。
提前致谢。
< asp:textbox id = txt runat = server maxlength = 5 > < / asp:textbox >
< asp:RegularExpressionValidator ID = rev runat = server ControlToValidate = txt
ErrorMessage = 输入正确的车间订单
ValidationExpression = ^ \d +
> < / asp:RegularExpressionValidator >
你好,
参考下面的解决方案,
< asp:TextBox ID = txtofficeTel runat = server Maxlength = 5
宽度 = 30px > < / asp:TextBox >
< asp:RegularExpressionValidator ID = RegularExpresphone1 ValidationGroup = phone 显示 = 动态
ControlToValidate = txtofficeTel runat = 服务器 ErrorMessage = 输入有效的电话号码。 < span class =code-attribute>
SetFocusOnError = True ValidationExpression = ^ \d {5}
Dear Friends,
I have two textbox on my webpage
Example as :
Office Telephone No : TEXTBOXOffTel
Extension : TEXTBOXextension
Now my requirement is - in TEXTBOXOfftel user must enter only numbers not alphabets and numbers must be only 5 digits.
and in TEXTBOX extension user must enter only numbers not alphabets and numbers must be only 4 digits.
Please can u help me.
Thanks in advance.
解决方案
Try this
<asp:textbox id="txt" runat="server" maxlength="5" ></asp:textbox> <asp:RegularExpressionValidator ID="rev" runat="server" ControlToValidate="txt" ErrorMessage="Enter correct shop order" ValidationExpression="^\d+
"></asp:RegularExpressionValidator>
Hello,
refer below solution,
<asp:TextBox ID="txtofficeTel" runat="server" Maxlength="5" Width="30px" ></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpresphone1" ValidationGroup="phone" Display="Dynamic" ControlToValidate="txtofficeTel" runat="server" ErrorMessage="Enter Valid Phone Number." SetFocusOnError="True" ValidationExpression="^\d{5}
这篇关于验证文本框仅输入5个数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文