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

enter key submit

Status
Not open for further replies.

ace21

Programmer
Joined
Jul 11, 2001
Messages
4
Location
US
Can someone explain to me why the enter key will work on this one with an extra text box and not the second one.

----enter key from text box will work
<form name=form1 action=whocares method=post>
<Table width=100% border=0 cellpadding=3>
<TR>
<TD align=center><B>Search by Keyword(s):
<input type='text' name='keyword' size='50' maxlength=50>
<input type=text name=nothing>
<input type=submit value='Search' name=submit>
</TD></TR></table>
</form>

----enter key from text box will not work
<form name=form1 action=whocares method=post>
<Table width=100% border=0 cellpadding=3>
<TR>
<TD align=center><B>Search by Keyword(s):
<input type='text' name='keyword' size='50' maxlength=50>
<input type=submit value='Search' name=submit>
</TD></TR></table>
</form>

Ace21
 
Well, in IE both forms are being submited with enter key.
???

Sergio M. Netto.
 
Try stopping it in javaScript using a function
function trapKey(eve)
{
var strEventType = eve.type;
if(strEventType.toUpperCase() == &quot;CLICK&quot;)
{
return true;
}
else
{
return false;
}
}

Pass the default event object from where ever you are calling and this will stop the Enter key from submitting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top