I have one HTML text box (for quantity) and two HTML buttons (Add, Cancel) inside my form.
<form>
<input type="number" min="1" max="100" required />
<button type="button">Add</button>
<button type="button">Cancel</button>
</form>
I do not want my second button (cancel) to validate the form when clicked.
Is this possible? In ASP.NET, I can use CausesValidation="false" to not trigger the validation.
try this one.it works fine.It will work on submit button
You could use the formnovalidate-option on the cancel-button, like this:
See Symfony2 form validation with html5 and CANCEL button
If you have the input button as
runat=server
then you must have the propertycausesvalidation="false"
or else if you are simply using html input type button for cancel usejavascript
to redirect to your page on click of cancel.For eg. 1)
2)
Try this;
I changed your code: What you want is that your form should not be validated on click of cancel, so that's why i added the formnovalidate to the button cancel.
Try to add
formnovalidate
attribute to your cancel buttonTry this code at asp.net 5enter link description here button control
Aldo Flores Reyes @alduar .net news