vb.net 单击取消按钮时如何绕过必填字段验证?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27006739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to bypass required field validation when clicking the cancel button?
提问by sd4ksb
I've used HTML input type for my textboxes to utilize the required attribute. now my dilemma is i cannot go out of the page without filling-up the fields with required attributes. Ive tried using causeValidation set to false but its not working. i can not change my textboxes to asp textboxes because it's going to be a large changes in the page. is there any other way to this?
我已经将 HTML 输入类型用于我的文本框以利用 required 属性。现在我的困境是我不能在不填写具有必需属性的字段的情况下离开页面。我试过将causeValidation 设置为false 但它不起作用。我无法将我的文本框更改为 asp 文本框,因为这将是页面中的一个大变化。还有其他方法吗?
<asp:Button runat="server" ID="buttonCancel" CssClass="cu-btn-direction" style="float:right; margin-right: 15px; margin-bottom: 60px;" Text="Cancel" CausesValidation="false" />
EDIT:
编辑:
I tried adding validation group but didn't work... what works is setting the UseSubmitBehavior to false http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.usesubmitbehavior%28v=vs.110%29.aspxbut as explained in the link it will not work without js enabled. any other way?
我尝试添加验证组但没有用...什么工作是将 UseSubmitBehavior 设置为 false http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.button.usesubmitbehavior%28v =vs.110%29.aspx但如链接中所述,如果不启用 js,它将无法工作。任何其他方式?
回答by aRyhan
use formnovalidate
使用表单验证
<input type="submit" value="Cancel" formnovalidate>
this bypass all form validation like required
这绕过所有表单验证,如所需

