Send form when hitting enter

Posted by Álvaro G. Vicario on Stack Overflow See other posts from Stack Overflow or by Álvaro G. Vicario
Published on 2010-03-30T14:28:51Z Indexed on 2010/03/30 14:33 UTC
Read the original article Hit count: 377

Filed under:
|
|
|

I have a form in a jQuery enabled site. The form does not feature an <input type="submit"> button. For that reason, it's not submitted when you hit enter. What's the recommended way to emulate such behaviour?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head><title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript"><!--
$(function(){
    $("form input:first").focus();
});
//--></script>
</head>
<body>

<form action="" method="post">
<input type="text" name="user">
<input type="password" name="pass">
</form>

</body>
</html>

© Stack Overflow or respective owner

Related posts about html

Related posts about forms