Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: Tab and Enter keys

Tab and Enter keys 4 years 1 week ago #83619

  • WizzardOne
  • WizzardOne's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
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 administrator has disabled public write access.

Tab and Enter keys 4 years 1 week ago #83680

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6129
  • Thank you received: 1360
  • Karma: 535
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 administrator has disabled public write access.

Tab and Enter keys 2 years 10 months ago #99772

  • duvemyster
  • duvemyster's Avatar
  • Offline
  • Premium Lime
  • Posts: 24
  • Thank you received: 5
  • Karma: 2
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 administrator has disabled public write access.

Tab and Enter keys 1 year 6 days ago #122861

  • JanE
  • JanE's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 8
  • Thank you received: 3
  • Karma: 1
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 administrator has disabled public write access.

Tab and Enter keys 1 year 5 days ago #122864

  • Bigred
  • Bigred's Avatar
  • Offline
  • Senior Lime
  • Posts: 70
  • Thank you received: 27
  • Karma: 5
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.
$(document).ready(function() {
    $('input').on('keydown keypress', function(e) {       
        if(e.keyCode === 13) {
            return false;
        }      
    });
});
The administrator has disabled public write access.

Tab and Enter keys 1 year 5 days ago #122868

  • Bigred
  • Bigred's Avatar
  • Offline
  • Senior Lime
  • Posts: 70
  • Thank you received: 27
  • Karma: 5
To trigger the next button, try this.
$(document).ready(function() {
    $('input').on('keydown keypress', function(e) {       
        if(e.keyCode === 13) {
            e.preventDefault();
	    $('#movenextbtn').click();
        }      
    });
});
The administrator has disabled public write access.

Tab and Enter keys 1 year 4 days ago #122918

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9281
  • Thank you received: 1324
  • Karma: 384
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 developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.

Tab and Enter keys 3 days 7 hours ago #139563

  • adridg
  • adridg's Avatar
  • Online
  • Junior Lime
  • Posts: 30
  • Karma: 0
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 administrator has disabled public write access.

Tab and Enter keys 3 days 4 hours ago #139564

  • Bigred
  • Bigred's Avatar
  • Offline
  • Senior Lime
  • Posts: 70
  • Thank you received: 27
  • Karma: 5
The script above that has return false should work for you.
The administrator has disabled public write access.
The following user(s) said Thank You: adridg

Tab and Enter keys 2 days 12 hours ago #139589

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9281
  • Thank you received: 1324
  • Karma: 384
Or just remove the line 80 to 84
Assistance on LimeSurvey forum and LimeSurvey core developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.
The following user(s) said Thank You: adridg

Tab and Enter keys 2 days 5 hours ago #139616

  • adridg
  • adridg's Avatar
  • Online
  • Junior Lime
  • Posts: 30
  • Karma: 0
DenisChenu wrote:
Or just remove the line 80 to 84

Didn´t work for FireFox and Chrome.
The administrator has disabled public write access.

Tab and Enter keys 2 days 4 hours ago #139617

  • adridg
  • adridg's Avatar
  • Online
  • Junior Lime
  • Posts: 30
  • Karma: 0
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 administrator has disabled public write access.

Tab and Enter keys 1 day 19 hours ago #139623

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9281
  • Thank you received: 1324
  • Karma: 384
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
$(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 developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.
The following user(s) said Thank You: adridg
Moderators: ITEd
Time to create page: 0.587 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form