Topic: Login Modal - best way to have the Enter Key click the Login Button?

cdenby pro asked 4 years ago


I'd like to have the enter key click the login button on a login modal. What's the cleanest way to do this?

cdenby pro commented 4 years ago

If the username or password has focus, the enter key should click the login button.

Mikołaj Smoleński staff answered 4 years ago


Hi, I suggest to use the following code:
$('input').on('keypress', (event)=> {
        if(event.which === 13){
            $('.login-button').click();
        }
});
Best Regards

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • User: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags