Custom login page, submit auth form with enter

0
Hi, when creating a custom login page in Mendix (thus not the HTML page), you can use the authentication widgets for username, password and the sign in button. Great! The problem is that if you use this, the normal form behaviour to submit the form with pressing enter when the user has filled in the username and password doesn't work. Users need to click on the submit button with the mouse.   Do you have a solution for this?
asked
5 answers
2

Place a HTML/JS snippet with the following code on the signin page and replace with your own classes:

 

(function() {
    document.addEventListener("keydown", function(e) {
        if (e.keyCode !== 13) return; // ignore if the pressed key is not 'Enter' key.
        var inputField = document.querySelector(".myPasswordInput input");
        var btn = document.querySelector(".mySubmitButton");
        if (inputField && btn && document.activeElement === inputField) {
            btn.click();
        }
    });
});

 

answered
1

Hi Peter,

As Sjors mentioned, you can add a HTML/JS snippet to your page. There are also widgets available that you can use for this and perhaps also for other hotkeys, e.g. Mendix Marketplace - Keyboard Shortcut

Hope this helps!

answered
0

Hi Peter,

 

Within the properties pane of the wiget you can set the onEnter event.

 

 

Hope this will help.

Jan

answered
0

Hi Peter,

Use the html snippet in your login page with below code and configure the login/sign-in button class name as follows:

 

 

Hope it will resolve your query.

answered
0

I understand that with custom javascript you can get this job done.

However, I am not happy with that.. The more custom javascript, the harder to maintain your apps.

 

I have submitted an idea on the forum: https://forum.mendix.com/link/ideas/3473.

Please give it an upvote if you also think this should be included

answered