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

Stop enter from submitting form

Status
Not open for further replies.

RexJacobus

Programmer
Dec 10, 2001
47
NZ
I am creating a lost password form. The user puts in what he thinks his player name might be and the page goes and retrieves anything similar and asks the player if any of them looks right and if so choose the radio button that is your player name and click the submit button. The form then emails you your password.

I do not want the email to be sent when enter is pressed but it keeps happenning. This has resulted in a lot of people getting emails with their pwds that they didn't ask for.

Here is my code, how do I stop Enter from submitting?

------------------------------

<form action=/cgi-bin/lost_passwordTest.cgi method=post>
My login name is
<input type=text name=pname value='rex' width=10> ... or something containing this string.
<br><br><br>

<TABLE BORDER=0 CELLPADDING=2 WIDTH="100%"><TR><td></td><TD><p align=left><b>Player Name</b></TD><TD><p align=left><b>Email</b></TD><TD><p align=left ><b>Country</b></TD><td><b>Registered on</b></td><TR><TR><td><input type=radio name=uid value=37704 ></td><TD><P ALIGN=left><A HREF="/cgi-bin/gs_edit.cgi?pname=valtrex">valtrex</A></TD><TD><P ALIGN=left><script>obPrint('0687265663d276d61696c746f3a76766161406e616e61
6e2e636f6d273e76766161406e616e616e2e636f6d3c2f613e','3c612')</script></TD>
<TD><P ALIGN=left>Hungary</TD><TD>December
14, 2006 at 05:02:23 GMT
</TD></TR>
<TR><td><input type=radio name=uid value=35167 ></td><TD><P ALIGN=left><A HREF="/cgi-bin/gs_edit.cgi?pname=rexelrat">rexelrat</A></TD><TD><P ALIGN=left><script>obPrint('0687265663d276d61696c746f3a656c69736573636872
6f74656e40686f746d61696c2e636f6d273e656c697365736368726f74656e40686f746d6
1696c2e636f6d3c2f613e','3c612')</script></TD><TD><P ALIGN=left>Netherlands</TD><TD>July
18, 2006 at 14:23:16 GMT
</TD></TR>
<TR><td><input type=radio name=uid value=35045 ></td><TD><P ALIGN=left><A HREF="/cgi-bin/gs_edit.cgi?pname=RexJacobus">RexJacobus</A></TD><TD><P ALIGN=left><script>obPrint('0687265663d276d61696c746f3a6a616d65732e7269736
e657240676d61696c2e636f6d273e6a616d65732e7269736e657240676d61696c2e636f6d3
c2f613e','3c612')</script></TD><TD><P ALIGN=left>New Zealand</TD><TD>July
10, 2006 at 23:46:20 GMT

</TD></TR>
<TR><td><input type=radio name=uid value=27969 checked></td><TD><P ALIGN=left><A HREF="/cgi-bin/gs_edit.cgi?pname=rex">rex</A></TD><TD><P ALIGN=left><script>obPrint('0687265663d276d61696c746f3a7265785f72657840686
f746d61696c2e636f6d2e6175273e7265785f72657840686f746d61696c2e636f6d2e61753
c2f613e','3c612')</script></TD><TD><P ALIGN=left>Australia</TD><TD>August
20, 2005 at 02:45:18 GMT
</TD></TR>
<TR><td><input type=radio name=uid value=10440 ></td><TD><P ALIGN=left><A HREF="/cgi-bin/gs_edit.cgi?pname=ReRex">ReRex</A></TD><TD><P ALIGN=left><script>obPrint('0687265663d276d61696c746f3a6669736368724074766
e6574776f726b2e6875273e6669736368724074766e6574776f726b2e68753c2f613e','3c
612')</script></TD><TD><P ALIGN=left>Hungary</TD><TD>May
22, 2003 at 19:11:38 GMT
</TD></TR>
</TABLE></P>If one of the above users is you,
and your email address listed is valid, then tick the box

and click on - Send password. If not, you're out of luck.<br>
<br><input type=submit value='Send Password
'>
</form>

 
Javascript is probably the only way you can achieve this. Either by trapping the [tt]onkeypress[/tt] event and checking for enter, or by having a confirmation prompt in the [tt]onsubmit[/tt] event of the form itself.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Additionally, it sounds like you might be better off asking for the player's email address, rather than player name. Then at least it would prevent annoying emails being sent incorrectly in situations where a player selects an incorrect player name (that they thought was theirs) to generate the password reminder.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top