Showing posts with label enterkey. Show all posts
Showing posts with label enterkey. Show all posts

Wednesday, 29 April 2015

Enter to onsubmit in html or catching Enter key?

Here is the solution, you are looking for

HTML CODE:

<form id="myform" onsubmit="return myFunction()">
          <input type="text" id="textbox">
          <input type="submit" id="mysubmitid" value="Go">

</form>


JAVA SCRIPT:

$(document).ready(function()
{
    $('#textbox').keypress(function(ev)
    {
            //If user pressed Enter Key then trigger Submit click
            if(ev.keyCode==13)
            $('#mysubmitid').click();
            });
});