Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Tab and Enter keys

More
13 years 1 month ago #83619 by WizzardOne
Hello, I have just launched a survey, and had a user report that if they hit the tab or enter key after filling in a question on the form, they are closed out and the survey acts like it was the submit key.
Have I missed a setting?
The topic has been locked.
More
13 years 1 month ago #83680 by tpartner
Replied by tpartner on topic Tab and Enter keys
Depending on the number and type of inputs, it is normal behaviour for browsers to submit a form when the Enter key is pressed.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
More
11 years 11 months ago #99772 by duvemyster
Replied by duvemyster on topic Tab and Enter keys
While recognizing that this is standard browser behavior, have any of you explored ways of over-riding it in any of your instances of limesurvey?

Any recommendations besides the following?
stackoverflow.com/questions/585396/how-t...to-submit-a-web-form
The topic has been locked.
More
10 years 1 month ago #122861 by JanE01
Replied by JanE01 on topic Tab and Enter keys
There is a strange difference between the behaviour on a iPad and, for instance, in Chrome on Windows. On a iPad the Go button (or the Enter key if you have a BT keyboard) triggers the previous submit button. On Chrome the Enter key does a Next submit.

'Next' is preferable. How do I change that for the iPad?
The topic has been locked.
More
10 years 1 month ago #122864 by Bigred01
Replied by Bigred01 on topic Tab and Enter keys
I'm not sure what keyCode the "go" button returns for iPhone but from what i have read its also 13. The below script should prevent most instances of enter submitting the form. Textarea wont be affected by this.
Code:
$(document).ready(function() {
    $('input').on('keydown keypress', function(e) {       
        if(e.keyCode === 13) {
            return false;
        }      
    });
});
The topic has been locked.
More
10 years 1 month ago #122868 by Bigred01
Replied by Bigred01 on topic Tab and Enter keys
To trigger the next button, try this.
Code:
$(document).ready(function() {
    $('input').on('keydown keypress', function(e) {       
        if(e.keyCode === 13) {
            e.preventDefault();
      $('#movenextbtn').click();
        }      
    });
});
The topic has been locked.
More
10 years 1 month ago #122918 by DenisChenu
Replied by DenisChenu on topic Tab and Enter keys
Complete test of key:
git.framasoft.org/Shnoulle/SkeletonQuest...ster/template.js#L74

Here, i focus on enter or sumbmit, can be updated to "click".

I think default behaviour must be save but not go next ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
9 years 1 month ago #139563 by adridg
Replied by adridg on topic Tab and Enter keys
I´m using LS Version 2.50+ Build 160718
and I´ve just notice that the if I press "enter" in the keyboard this will do the same as pressinf button "Next"
and what is worse, the same as "Submit" buttom at the end of my survey.
How do I disable this?
I want only "Next" and "Submit" buttom to do this.
Thak you
The topic has been locked.
More
9 years 1 month ago #139564 by Bigred01
Replied by Bigred01 on topic Tab and Enter keys
The script above that has return false should work for you.
The following user(s) said Thank You: adridg
The topic has been locked.
More
9 years 1 month ago #139589 by DenisChenu
Replied by DenisChenu on topic Tab and Enter keys
Or just remove the line 80 to 84

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The following user(s) said Thank You: adridg
The topic has been locked.
More
9 years 1 month ago #139616 by adridg
Replied by adridg on topic Tab and Enter keys

DenisChenu wrote: Or just remove the line 80 to 84


Didn´t work for FireFox and Chrome.
The topic has been locked.
More
9 years 1 month ago #139617 by adridg
Replied by adridg on topic Tab and Enter keys

Bigred wrote: The script above that has return false should work for you.


Sorry if i´m asking basic questions, but i´m new in this thing
I tried to copy the script that y told, but it retirned error.
I have to write the exactly script in the css template? In which line of it?
Thank you again.
The topic has been locked.
More
9 years 1 month ago #139623 by DenisChenu
Replied by DenisChenu on topic Tab and Enter keys

adridg wrote:

DenisChenu wrote: Or just remove the line 80 to 84


Didn´t work for FireFox and Chrome.

It's not an answer .....

Put this at top of your template.js file
Code:
$(document).on('keypress','input[type=text],#limesurvey select',function(e){
    var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
    if (key == 13) {
      e.preventDefault();
    }
  });

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The following user(s) said Thank You: adridg, ConradNg
The topic has been locked.
More
5 years 10 months ago - 5 years 10 months ago #190018 by Diegoteca
Replied by Diegoteca on topic Tab and Enter keys

Bigred01 wrote: To trigger the next button, try this.

Code:
$(document).ready(function() {
    $('input').on('keydown keypress', function(e) {       
        if(e.keyCode === 13) {
            e.preventDefault();
      $('#movenextbtn').click();
        }      
    });
});



Hello! I am working with 3.17.9 + 190731 and with the Bootswatch theme.

The code above works great for me. I copied this in "Files.js" of advanced options.

But I have a problem with the numerical questions when the following questions (also numerical) have to be hidden / shown according to conditional fork. More precisely, with some numbers when I press "enter" it goes right to the immediate next question. But for the options that I need to "skip" two or more questions these are actually "hidden" and the correct question appears below but the cursor remains on the initial question. One fact: if "tab" is pressed, the cursor effectively points to the desired question.


Is it as if the code above would be useful for "movenextbtn" and maybe when there are jumps, another command must be added?

First, I thought the problem was my misuse of the configuration condition, but the logical file shows no problem.

In the example that I attach if you put a number other than 1 in the first question and press "enter" you should skip to the last question. The other questions are effectively hidden but the cursor only jumps with the "Tab" key.

Thanks in advance,
Diego
Last edit: 5 years 10 months ago by Diegoteca.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose