Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to bypass required field validation when clicking the cancel button?

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?

<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.aspx but as explained in the link it will not work without js enabled. any other way?

like image 524
sd4ksb Avatar asked Nov 19 '14 00:11

sd4ksb


1 Answers

use formnovalidate

<input type="submit" value="Cancel" formnovalidate>

this bypass all form validation like required

like image 137
aRyhan Avatar answered Oct 30 '22 06:10

aRyhan