How To Make Enter The Submit Button In A Form January 08, 2024 Post a Comment I have a form for logging into my website. I need to make it so that when the user hits enter, the form submits. How can I do this? Please provide code. Thanks. Solution 1: Have you actually tried anything? You need to add an <input type="submit"> and hide it with CSS so that the browser knows what to trigger when enter is pressed, yet still not show a button. For the sake of accessibility and ease of use, I'd show the button even if not that many people use it (enter is much nicer). Solution 2: add a handler to on keydown and check for keycode == 13. Make this submit the form like belowBaca JugaSimple Xmlhttprequest Fails With Access-control-allow-origin Header NullJSON Bad Format In Post MethodJQuery Ajax POST Data Is Empty On The Server For Some ClientsfunctionaddInputSubmitEvent(form, input) { input.onkeydown = function(e) { e = e || window.event; if (e.keyCode == 13) { form.submit(); returnfalse; } }; } CopySolution 3: This should happen by default. In my experience some browsers require an <input type=submit> field, but generally this is not a requirement. Share You may like these postsAsp.net -> Has Anyone Dealt With Image Urls That Are Over 2500 Characters?JSON Bad Format In Post MethodSimple Xmlhttprequest Fails With Access-control-allow-origin Header NullJQuery Ajax POST Data Is Empty On The Server For Some Clients Post a Comment for "How To Make Enter The Submit Button In A Form"
Post a Comment for "How To Make Enter The Submit Button In A Form"