I have a web form with several fields and two buttons. All fields are require validation.
How can I group the fields with html5 required attribute based on each of the individual buttons, like validation groups?
Sadly there is no way. ASP.NET has the "only one big form approach" and html5 validation is tied to the form.
The only workaround is to disable HTML validation for one of the 2 button with the formnovalidate
attribute:
<asp:button id="button" runat="server" text="submit" formnovalidate="formnovalidate" />
or you should create some custom JavaScript:
How can I void a form action and execute jQuery when all HTML form elements are validated?
How to force an HTML form to validate without submitting it via jQuery