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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

131495 Jul 12,2017 08:32 PM Jul 13,2017 10:57 AM ASP.NET MVC 1
loading
Tags: Grid
Dongil Shin
Asked On July 12, 2017 08:32 PM

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,


Thavasianand Sankaranarayanan [Syncfusion]
Replied On July 13, 2017 10:57 AM

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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;