We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

prevent submit validation on Enter keydown

Hi team,

I attempted to try this solution but it seems SFtextbox doesn't accept handler event and preventdefault..


<input value="@name" type="text" @onkeydown="@onKeydown" @onkeydown:preventDefault="@isPreventKey" /> @code { private string name { get; set; } private bool isPreventKey { get; set; } private void onKeydown(KeyboardEventArgs args) { if(args.Key == "a") { this.isPreventKey = true; } } }

I also tried this solution, however it prevent the submit method upon "enter" but it still shows the validation. I want to show the validation error only upon clicking of "save" button,.

CssClass="e-outline e-success"


Placeholder="Scan Item Code"





<button type="submit" @onclick="ShouldISubmit">Savebutton>

public bool shouldsubmit { get; set; } public bool entersubmit { get; set; }

public void InvalidSubmit()


if (shouldsubmit)


toastService.ShowError("Adjustment was not applied. Check for valid entries."); //toast



private void HandleValidSubmit()
    if (shouldsubmit) {

public void PreventSubmit(KeyboardEventArgs ev)
    if (ev.Key == "Enter")
        entersubmit = true;

public void ShouldISubmit()
    if (entersubmit)
        shouldsubmit = false;
        shouldsubmit = true;
    entersubmit = false;


here is the model

public partial class InventoryAdjustmentDetailEdit



public string itemcode { get; set; }


Best Regards,


1 Reply

SP Sureshkumar P Syncfusion Team February 22, 2023 11:59 AM UTC

Hi Tyrone,

You can refer the below forum solution to prevent the edit form submit and validation using JS Interop

Find the solution here: https://www.syncfusion.com/forums/173262/disable-form-submit-when-pressing-enter-after-combobox-edit?reply=S2QA6w


Sureshkumar P

Live Chat Icon For mobile
Up arrow icon