All buttons inside a editform triggers validation and submit

I have multiple buttons inside a EditForm, but only one (Save) should trigger submit. 

<div class="button-group">
<SfButton CssClass="e-primary" IsPrimary="true">Save</SfButton>
<SfButton CssClass="e-secondary" OnClick="OpenDialog" IsPrimary="false">More information</SfButton>
</div>

How can I make the second button not trigger validation and submit of form


3 Replies 1 reply marked as answer

KV Keerthikaran Venkatachalam Syncfusion Team February 8, 2024 04:42 PM UTC

Hi Art Vandelay,


After validating the provided query, it was observed that when clicking a button other than the submit button in the form, the default behavior of the HTML button click event was also being triggered. To resolve this issue, it is recommended to set the button type to "button" for all buttons within the form component, except for the submit button. Please refer to the code snippet and sample provided below.


<EditForm Model="@model" OnValidSubmit="handleSubmit">

     <SfButton CssClass="e-primary" IsPrimary="true">Save</SfButton>

    <SfButton CssClass="e-secondary" type="button" OnClick="OpenDialog" IsPrimary="false">More information</SfButton>

</EditForm>


Please let us know if you need any further assistance on this.


Regards,

KeerthiKaran K V


Attachment: ButtonSample_f76b0e7d.zip

Marked as answer

AV Art Vandelay February 8, 2024 08:40 PM UTC

Thanks! That solved my issue



KV Keerthikaran Venkatachalam Syncfusion Team February 9, 2024 03:54 AM UTC

You're welcome,  Art Vandelay. Get back to us if you need any other assistance.


Loader.
Up arrow icon