phpjayx Posted January 14, 2013 Share Posted January 14, 2013 If I already have a Submit button which send over a username and password. How do I allow the user to press the ENTER key as an alternative to pressing the Submit button? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 14, 2013 Share Posted January 14, 2013 If it's an HTML form, that is default functionality. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted January 14, 2013 Share Posted January 14, 2013 Unless you've done something to override the default behaviour, all browsers (I know of) support this out of the box. Quote Link to comment Share on other sites More sharing options...
codefossa Posted January 14, 2013 Share Posted January 14, 2013 Unless you are wanting to remove the submit button, then the two above me are correct. If you do want to remove it and still be able to submit .. Something like this could work. window.document.querySelector("#myFormId").addEventListener("keyup", function(event) { if (event.which == 13) this.submit(); }, false); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.