身份字段验证 [英] ID field validation
本文介绍了身份字段验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是这个网站的新手.
我想在asp.net中使用正则表达式验证,以防止用户在文本开头插入数字或特殊字符.
如果用户输入12abcd或* abcd,则不允许这样做,但如果输入abcd12或abc12d *,则允许这样做.
我该如何实现?
感谢您的帮助.
Hi,
I am new in this site.
I want to use regular expression validation in asp.net to prevent user inserting digit or special character at the start of the text.
If the user entered 12abcd or *abcd this is not allowed but in case abcd12 or abc12d* this is allowed.
How can I achieve this?
Thank you for helping me.
推荐答案
尝试一下:
Try this:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:RegularExpressionValidator
ID="RegularExpressionValidator1" ValidationExpression="^[_A-Za-z][\S]*
" ControlToValidate =" TextBox1" 显示 =" 运行率 =" ErrorMessage 无效的输入." ">< ; /asp:RegularExpressionValidator > < br > < asp:Button ID =" runat 服务器" 文本 提交" /
" ControlToValidate="TextBox1" Display="Dynamic" runat="server" ErrorMessage="Invalid Input."></asp:RegularExpressionValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit" />
这可能对您有所帮助.
正则表达式速查表 [ ^ ]
This may help you.
Regular Expression Cheat Sheet [^]
这篇关于身份字段验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文