在 VB.NET 中,我正在尝试验证
<asp:textbox id="name" runat=server> </asp:textbox>
文本框值不应超过 200 个字符,并且文本框只接受字符串。
哪个验证器会是一个不错的选择?我想使用自定义验证器,它可以与字符串值一起使用吗?
在 VB.NET 中,我正在尝试验证
<asp:textbox id="name" runat=server> </asp:textbox>
文本框值不应超过 200 个字符,并且文本框只接受字符串。
哪个验证器会是一个不错的选择?我想使用自定义验证器,它可以与字符串值一起使用吗?
<asp:RegularExpressionValidator ID="regexTextBox1"
ControlToValidate="YourTextBoxID" runat="server"
ValidationExpression="^[\s\S]{0,200}$" Text="200 characters max" />
您可以完全避免使用自定义验证器。
如果您只需要强制文本框字段的最大长度,您可以使用它
<asp:TextBox MaxLength="200" id="name" runat=server> </asp:TextBox>