I am trying to use an image based hyperlink button for submitting form. So i am able to click on the image and submit form.
Now requirement is to submit form if enter key is pressed in page. I copied some code from net but unable to work.
Below is my code. Please correct me if i am going wrong somewhere.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="login-box.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="s/scripts/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
$('#myform').keypress(function(event) {
if (event.which == 13) {
$('#myform').submit();
}
});
</script>
</head>
<body>
<form name="myform" action="/home" method="post">
Username:<input name="username" class="form-login" title="Username" value="" size="30" maxlength="2048" />
Password:<input name="password" type="password" class="form-login" title="Password" value="" size="30" maxlength="2048" />
<a href="#" onclick="document.myform.submit();return false;"><img alt="Login" src="login-btn.png" width="103" height="42" style="margin-left:90px;" /></a>
</form>