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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent Form Submit 1

Status
Not open for further replies.

Deadline

Programmer
Feb 28, 2001
367
US
Hi,

How to prevent the user from submitting the form by pressing Enter/Return Key ?

If this question is answered elsewhere in this forum, please let me know the URL.
Thank you very much.

RR


 
Hi,

If you use JavaScript you can create a global boolean variable that initially false. With onSubmit you'll return the value of that variable. The sbmit button will change that variable to true!
I think this works, perhaps there is another method!

Regards,
Luís Silva
 
Hi, what I do is instead of adding a submit button to the form I add a regular button to the form then on the onClick event of the button i call a javascript function that any validation that you want or just submit the form when the use rclicks the button. If they hit enter it will do nothing.
Example:
<html>
<head>
<script language =&quot;javascript&quot;>
function onSubmit()
{
document.formname.submit();

}

</script>
</head>

<body>
<input type=&quot;button&quot; name=&quot;cmdSubmit&quot; value=&quot;Submit&quot;
onClick=&quot;onSubmit()&quot;>

</body>
</html>

Good luck,
Frandazzo
NYC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top