简体   繁体   English

html 5验证和asp.net

[英]html 5 validation and asp.net

I have a quick question, I have a form and I have used the required="required" (HTML5 Validation) for my fields, and I have two buttons, RESET and SUBMIT, the validation should only work when the SUBMIT button is pressed, however when I click on the RESET button, which should clear the fields, still proceeds with the validation and prompting me that it is a required field, how can I assign the validation only to SUBMIT button. 我有一个快速的问题,我有一个表格,并且在字段中使用了required="required" (HTML5验证),并且有两个按钮RESET和SUBMIT,只有在按下SUBMIT按钮时验证才有效,但是,当我单击“重置”按钮(应清除字段)时,仍然继续进行验证并提示我这是必填字段,如何将验证仅分配给“提交”按钮。

<asp:TextBox ID="txtPolNo" runat="server" placeholder="Enter Policy Number" 
    BackColor="White" BorderColor="#C2C4CC" BorderStyle="Solid" Height="28px" 
    Width="135px" title="Enter Your Policy Number" required ></asp:TextBox>

Use Dev Tools (F12) and/or "View Source" to inspect the Reset button. 使用开发工具(F12)和/或“查看源代码”检查“重置”按钮。 Pay attention to what it may be doing for onclick , and for what the form may be doing for onsubmit and it should help point you in the right direction. 请注意onclick可能会做的事情以及onsubmit form可能会做的事情,这应该有助于您找到正确的方向。

If you copy and paste your "View Source" contents into SO we could better understand how your HTML is rendered. 如果将“查看源代码”内容复制并粘贴到SO中,我们将更好地理解HTML的呈现方式。 You may be using input type="submit" instead of input type="reset" for your "Reset" button, but no point in speculating without seeing your full code. 您可能在“重置”按钮上使用了input type="submit"而不是input type="reset" ,但是在没有看到完整代码的情况下进行推测毫无意义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM