April 14, 2013 asvignesh 0Comment

We can submit the html form page by pressing submit button and the shortcut way is pressing enter ( return ) button on keyboard after filling up the form

Here is the post to explain how to submit a form by pressing enter button using jQuery

Generally, a form is submitted when the user presses a submit button. However, sometimes, you may need to submit the form when the user press return key ( enter key)

Here is the code to submit the form by pressing the enter key

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
function formSubmit()
$('#submit_form').keypress(function (e) {
if (e.which == 13) {
//13 is the javascript keycode for return key
 // for more key code refer my previous post
 return false; //<---- Add this line
<form id="frm1" action="form_action.asp">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname" id=”submit_form”><br>
<input type="button" onclick="formSubmit()" value="Submit form">

6+ years of experience in building data protection, copy data management and storage management applications, automation software and plugins for private and public clouds

Disclaimer :

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. my thoughts and opinions change from time to time… This weblog is intended to provide a semi-permanent point in time snapshot and manifestation of the various memes running around my brain, and as such any thoughts and opinions expressed within out-of-date posts may not the same, nor even similar, to those I may hold today.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.