Disable submit on enter press in input LS3

More
5 months 4 days ago - 5 months 4 days ago #181639 by andrescevp
Hi people!

I has been crazy looking for a solution, but I can't...

Well, the thing is, that I have some selects that are handled by Select2.

It works, no problem.

I has been enabled the feature of tagging to can write free text, the point is that Select2 displys and searcher field to search options, when find your option then you can do click to select... or press enter (witch is the normal).

The problem is... when you press enter the form is submitted and do not want this.

Some way to prevent this?

I'm using limesurvey 3.

And yes, I check the workaround and was trying to do it myself... but I just can't find the proper way.

Thanks!
Last edit: 5 months 4 days ago by andrescevp.

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
5 months 4 days ago #181644 by jelo

andrescevp wrote: Well, the thing is, that I have some selects that are handled by Select2.

You seem to use somekind of workaround. Select2 is what?

You should provide the exact version of LimeSurvey and the theme used for the survey.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users

Please Log in or Create an account to join the conversation.

More
5 months 4 days ago #181645 by andrescevp
LimerSurvey 3.1

Select2 is a library to dynamize select ( select2.org/ )

template vanilla

Please Log in or Create an account to join the conversation.

More
5 months 4 days ago #181648 by andrescevp
I checked and doing this will remove the autosubmit on enter

ajaxHandler.unsetSubmit();

But keep doing validations and of course fail

Please Log in or Create an account to join the conversation.

More
5 months 4 days ago #181652 by andrescevp
sadly was a fake hype hahaha

Please Log in or Create an account to join the conversation.

More
5 months 3 days ago #181663 by DenisChenu
Maybe gitlab.com/SondagesPro/SurveyThemes/skel.../skelvanilla.js#L114

Because submit current form when using enter on a dropdown or a text input is the default behaviour of the browser.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
5 months 3 days ago #181741 by andrescevp
thanks.

I notice that limesurvey is triggering the enter key twice...
                $(document).on('keypress keyup keydown', '#limesurvey input[type=text],#limesurvey input[type=search],#limesurvey select,#limesurvey .select2-results__option',function(e){
                    var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
                    console.log(key);
                    if (key == 13 && e.ctrlKey != true ) {
                        cancelEvent(e);
                        var inputs = $(this).closest('form').find(':input:visible:enabled,select:visible:enabled,textarea:visible:enabled,button:visible:enabled');
                        if ((inputs.length-1) == inputs.index(this)) {
                            console.log('submit!');
                            $('.ls-move-submit-btn').focus();
                            return;
                        } else {
                            console.log('next!');
                            var nextElement = inputs.eq(inputs.index(this) + 1);
                            if ($(nextElement).data('select2')) {
                                $(nextElement).select2('open');
                                return false;
                            }
                            nextElement.focus();
                            return;
                        }
 
                        return false;
                    }
                });
 


console log:
index.php?r=survey/index&sid=939187:1441 100
index.php?r=survey/index&sid=939187:1441 65
index.php?r=survey/index&sid=939187:1441 97
index.php?r=survey/index&sid=939187:1441 83
index.php?r=survey/index&sid=939187:1441 115
index.php?r=survey/index&sid=939187:1441 68
index.php?r=survey/index&sid=939187:1441 83
index.php?r=survey/index&sid=939187:1441 65
index.php?r=survey/index&sid=939187:1441 68
index.php?r=survey/index&sid=939187:1441 100
index.php?r=survey/index&sid=939187:1441 65
index.php?r=survey/index&sid=939187:1441 97
index.php?r=survey/index&sid=939187:1441 83
index.php?r=survey/index&sid=939187:1441 115
2index.php?r=survey/index&sid=939187:1441 68
index.php?r=survey/index&sid=939187:1441 100
index.php?r=survey/index&sid=939187:1441 83
index.php?r=survey/index&sid=939187:1441 65
index.php?r=survey/index&sid=939187:1441 68
index.php?r=survey/index&sid=939187:1441 13
index.php?r=survey/index&sid=939187:1450 next!
index.php?r=survey/index&sid=939187:1441 13
index.php?r=survey/index&sid=939187:1446 submit!

some idea?

it do not stop the propagation... something to do with Pjax?

Please Log in or Create an account to join the conversation.

More
5 months 3 days ago #181743 by DenisChenu

andrescevp wrote: thanks.


it do not stop the propagation... something to do with Pjax?

I don't know … first things i do whan something don't work is disable ajaxMode (even if all work in fact …).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

More
5 months 3 days ago #181746 by andrescevp
this did the trick. Thanks.

But anyway... weird bug.

Please Log in or Create an account to join the conversation.

More
5 months 2 days ago #181771 by DenisChenu

andrescevp wrote: this did the trick. Thanks.

But anyway... weird bug.

bugs.limesurvey.org/view.php?id=14616 :)

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand .
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!