Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enter key on webpage form

Status
Not open for further replies.

DH

Programmer
Dec 8, 2000
168
When using an online form designed in FrontPage a user may hit the "Enter" key on the keyboard before completing the form. Well this submits the form before it is complete.

Is there a way to turn off or disable the "Enter" key from submitting the webpage form? I would like to user to have to click the submit button as the only way to submit the form.

Thanks, I don't use html or web pages much and not sure how to achieve this.

Thanks,

DH
 
it would be easier to validate the form on submiting it for empty fields otherwise you can catch the onKeyPress for the enter key.

example of what I mean
<html>
<head>

<script>
function val() {
if (frm.txt.value == &quot;&quot;) {
alert(&quot;Please enter values in all fields before submitting&quot;);

frm.txt.focus();
}
else
{
frm.sunmit();
}
}
</script>
</head>
<body>
<form name=&quot;frm&quot; onSubmit=&quot;val()&quot;>
<input type=&quot;text&quot; name=&quot;txt&quot;>
<input type=&quot;button&quot; value=&quot;submit&quot; onClick=&quot;val()&quot;>
</form>
</html>

no submit button
admin@onpntwebdesigns.com
 
I agree with onpnt about the general idea.
But it is better to call validation function from onSubmit event of the <form> tag, and use standard Submit button (without any onclick calls in it).
 
Thank you for the response. I will experiment with the information you have posted. Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top