我想验证文本框中是否包含特定文本,且不能为空。但是正则表达式验证器无法验证文本框是否为空。只有在文本框中输入内容时才会进行验证。
我该如何使正则表达式验证器即使在文本框为空时也能触发验证?
我应该同时使用必填验证器和正则表达式验证器吗?谢谢。
<asp:TextBox ID="txtcard" runat="server" MaxLength="16"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
ControlToValidate="txtcard" ErrorMessage="Please type credit card no"
ValidationExpression="^\d{16}$"></asp:RegularExpressionValidator>