我在aspx
页面上使用了验证,但它不起作用且没有错误
<div class="fourm-container">
<div class="single-input">
<span>email</span>
<input name="" type="text" runat="server" id="email" />
<asp:RequiredFieldValidator ID="RVemail" runat="server"
ErrorMessage="*" ControlToValidate="email" Display="Dynamic"
ForeColor="Red" SetFocusOnError="True"
ValidationGroup="one"></asp:RequiredFieldValidator>
</div>
<div class="button-container">
<input type="submit" id="Submit" value="login" name="submit"
onclick="AddCustomer" runat="server" validationgroup="one" />
</div>
答案 0 :(得分:0)
使用表单标记和结束div,我尝试了这个片段,可以看到验证正在进行。 (没有onclick)如果你看到它工作,那么onclick有一个问题。
<form id="form1" runat="server">
<div class="fourm-container">
<div class="single-input">
<span>email</span>
<input name="" type="text" runat="server" id="email" />
<asp:RequiredFieldValidator ID="RVemail" runat="server"
ErrorMessage="*" ControlToValidate="email" Display="Dynamic"
ForeColor="Red" SetFocusOnError="True"
ValidationGroup="one"></asp:RequiredFieldValidator>
</div>
<div class="button-container">
<input type="submit" id="Submit" value="login" name="submit" runat="server" validationgroup="one" />
</div>
</div>
</form>
答案 1 :(得分:0)
您无法在ValidationGroup="one"
中使用RequiredFieldValidator
。
试一试:
<asp:RequiredFieldValidator ID="RVemail" runat="server"
ErrorMessage="*" ControlToValidate="email" Display="Dynamic"
ForeColor="Red" SetFocusOnError="True">
</asp:RequiredFieldValidator>