Thursday, October 18, 2012

Jquery - Enter key submit for page

Following code helpful to handle to submit the button when enter key entered.


HTML:


<div onkeypress="loginOnEnterKey(event);">
..code goes here
<input type="button" onclick="login()">LOGIN</a>

</div>


JAVASCRIPT:

function loginOnEnterKey(event){
   if(event.keyCode == 13) {
            $('#btnlogin').focus();
            login();
    }
 }

No comments:

Post a Comment