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

how to prevent save when enter key pressed in the text field

Hi, I'm having a problem that preventing automatic save when enter key pressed in the text field.

the code I'm looking in as follows.


function CheckEnterKey() {
    if (event.which == 13) {        
        event.preventDefault();
        var s = $('.nextstepdetails').val();
        $('.nextstepdetails').val(s + "\n");
        $('.nextstepdetails').focus();        
    }
}


// Edit template functions for MultiLine textbox
function createML() {
    return "<textarea class='form-control nextstepdetails' rows='1' cols='50' style='word-wrap:break-word !important;' onkeydown='CheckEnterKey()' onkeypress='CheckEnterKey()'>{{:NextStepDetail}}</textarea>";
}

the text field is styled as textarea. I don't want autosave when 'Enter' key pressed. I want to keep editing the text and just click 'Save/Update' button to save.

Thank you in advance!
Kind Regards,


1 Reply

TS Thavasianand Sankaranarayanan Syncfusion Team July 13, 2017 02:57 PM UTC

Hi Dongil, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we suspect that you want to prevent the Grid to save by clicking on the enter button in keyboard. So, we suggest you to set “allowKeyboardNavigation” as “false“ for ejGrid control. 

Refer the below code example. 


@(Html.EJ().Grid<object>("HierarchyGrid") 
             
            .AllowPaging() 
 
            .AllowKeyboardNavigation(false) // disable keyboard navigation of Grid 
 
            ---------------- 
             
 .Columns(col => 
            { 
                ----------------- 
           }) 
) 



We have prepared a sample and it can be downloadable from the below location. 


Refer the help documentation. 


If we misunderstood your query then please get back to us. 

Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon