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

1

11

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?

Rockel answered 19/11, 2014 at 0:20 Comment(1)
Found this link useful to me... <#18203284> it works with or without js...Rockel
S
25

use formnovalidate

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

this bypass all form validation like required

Siva answered 22/12, 2014 at 18:49 Comment(1)
Or just change the type of input <input type="button" value="Cancel">Mousebird

© 2022 - 2024 — McMap. All rights reserved.