0

我有一个文本框 txtemailid,它有两个验证器RequiredFieldValidatorRegularExpressionValidator

<asp:TextBox ID="txtEMailId" CssClass="Text1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RFVtxtEMailId"
    runat="server"
    ErrorMessage="*"
    Display="Dynamic"
    ForeColor="Red"
    ControlToValidate="txtEMailId"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="REVtxtEMailId"
    runat="server"
    ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    Display="Dynamic"
    ErrorMessage="Invalid Email Format"
    ForeColor="Red"></asp:RegularExpressionValidator>

它显示以下错误

The ControlToValidate property of 'REVtxtEMailId' cannot be blank.
4

2 回答 2

2

您尚未指定应验证哪个控件。试试这个

<asp:RegularExpressionValidator ID="REVtxtEMailId"
    runat="server"
    ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    Display="Dynamic"
    ErrorMessage="Invalid Email Format"
    ForeColor="Red" ControlToValidate="txtEMailId"></asp:RegularExpressionValidator>
于 2012-12-24T18:20:55.053 回答
0

您尚未在正则表达式验证器中提供 ControlTo 验证属性。在 REVtxtEMailId 中添加此属性

于 2012-12-24T18:22:08.173 回答