Hi there,
It's a case of capturing the event when a key is pressed, checking to see if it's the Enter key, and submitting the form, right?
Try adding this to your form:
-
<form onkeypress="checkSubmit(event)">
-
And in the head of your document, add this:
-
<script type="text/javascript>
-
<!--
-
function checkSubmit(e)
-
-
if (window.event) { //For IE
-
switch (e.keyCode) {
-
case 13:
-
document.myform.submit();
-
return true;
-
break;
-
default:
-
return false;
-
break;
-
}
-
} else if (e.which) {
-
switch (e.which) {
-
case 13:
-
document.myform.submit();
-
return true;
-
break;
-
default:
-
return false;
-
break;
-
}
-
}
-
//--></script>
-
Replace myform with the name of your form in the above code and it should work fine.
The above code is provided with a little help from
W3Schools.
Hope this helps.
medicineworker
P.S. I moved your thread to the Javascript forum cause the answer is JS-based.