Forum Index

No notifications
Notifications

Favorites

No favorites found
Ask the community Need help to achieve something? - Ask the Community
Join the Conversation > Ask the community > Enter key issue View modes: 
User avatar
KnowledgeKube Staff
KnowledgeKube Staff
matt - 26/04/2017 11:33:29
   
RE:Enter key issue

Hi Din,

Nice work! Good to know you were able to create bespoke functionality to support your requirements.

Kind regards.


User avatar
Advanced member
Advanced member
Din TIR - 25/04/2017 10:14:39
   
RE:Enter key issue

Hi Matt,

Thanks for clarifiying the issues.

Here is the script I use to for both MaskPassword and DataSourceGrid Textbox.

function EndRequestHandler(sender, args) {
    if (args.get_error() == undefined) {
        SetClientBindings();
    }                   
}

function SetClientBindings() {    
    $(".kk_MaskPassword_OnEnterOverride input").keypress(function(e) {
        /* on enter key press */
        if (e.keyCode == 13) {
            e.preventDefault();
            
            if($(".kk_MaskPassword_OnEnterButtonSubmit")[0]) {
                $('.kk_MaskPassword_OnEnterButtonSubmit input[type="submit"]:nth-child(1)').trigger('click');
            }
        }
    });
    
    $(".kk_DS_Textbox_OnEnterOverride input[type='text']").keypress(function(e) {
        /* on enter key press */
        if (e.keyCode == 13) {
            e.preventDefault();
            
            if($(".kk_DS_Textbox_OnEnterButtonSubmit")[0]) {
                $('.kk_DS_Textbox_OnEnterButtonSubmit input[type="submit"]:nth-child(1)').trigger('click');
            }
        }
    });
}

$(document).ready(function() {
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(EndRequestHandler);
    SetClientBindings();
});

  • To stop the MaskPassword to submit on enter key, I just need to add the style class "kk_MaskPassword_OnEnterOverride" to the FreeText.
  • To stop the DataSourceGrid Textbox to submit on enter key, I just need to add the style class "kk_DS_Textbox_OnEnterOverride" to the DataSourceGrid.
  • There are also addon style class, when the enter key is press for MaskPassword and DataSourceGrid Textbox, we can indicated a button to submit by adding the style class "kk_MaskPassword_OnEnterButtonSubmit" or "kk_DS_Textbox_OnEnterButtonSubmit" to the Button submitting respectively.

 


User avatar
KnowledgeKube Staff
KnowledgeKube Staff
matt - 10/04/2017 16:39:28
   
RE:Enter key issue

Hi Din,

Sorry for the delay in getting back to you on this. As it stands, a regular Free Text question is designed not to initiate a post-back or button click when the Enter key is pressed. As you rightly stated, applying the MaskPassword parameter to a free text question will cause that question to trigger a button when the Enter key is pressed, and a TextBox column field will have a similar reaction.

All of this behaviour is by design. To override the default behaviour, you could create a custom style class for specific question types, and have a script catch certain key presses made when the question has focus, in order to trigger a post-back or button click.

Kind regards.


1 2
RSS Feed