Topic: Login Modal - best way to have the Enter Key click the Login Button?
cdenby pro asked 6 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?
Mikołaj Smoleński staff answered 6 years ago
Hi,
I suggest to use the following code:
$('input').on('keypress', (event)=> {
if(event.which === 13){
$('.login-button').click();
}
});
Best Regards
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
Answered
Specification of the issue
- ForumUser: Pro
- Premium support: No
- Technology: MDB jQuery
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
Tags
cdenby pro commented 6 years ago
If the username or password has focus, the enter key should click the login button.