Reputation: 3636
I have a razorpage containing two button for submits(Post). One is submitting new entries entered on the page, and the other is deleting already added entries. The new entries and existing entries are all in the same form and both use the same model. I use page handlers to control which method is executed.
My problem is that when I click the delete button on existing entries I get client side validation for the inputfields from the model used when creating new entries.
Is there a way to disable client side validation for the field used when creating new entries in my delete button? or is it possible to send only the button in the POST request to avoid validation?
<button asp-route-id="@line.Id" asp-page-handler="DeleteRow" accesskey="" type="submit" class="btn btn-default pull-left">
<span class="glyphicon glyphicon-trash"></span>
</button>
Here is a photo of the scenario. the first line is used to create new entries is SQL., second line is fetched from SQL. clicking the delete button(POST) on second row causes client side validation on first row and prevents submit/POST).
The validation is correct when submitting the form for a new entry, but need to prevent the validation when deleting an existing entry.
Upvotes: 1
Views: 1545
Reputation: 3636
I found the answer, In the jquery.validate.js there was exceptions added to avoid validation.
// allow suppressing validation by adding the html5 formnovalidate attribute to the submit button
if ( $( this ).attr( "formnovalidate" ) !== undefined ) {
validator.cancelSubmit = true;
}
<button asp-route-id="@line.Id" formnovalidate asp-page-handler="DeleteRow" accesskey="" type="submit" class="btn btn-default pull-left">
<span class="glyphicon glyphicon-trash"></span>
</button>
Upvotes: 1