
February 22nd, 2006, 08:19 AM
|
|
Contributing User
|
|
Join Date: Feb 2006
Posts: 32
Time spent in forums: 8 h 29 m 50 sec
Reputation Power: 5
|
|
|
Enter Key Calls Function
I have a javascript function that checks that a text box has 3 characters or more and then submits the form.
The problem I have is that if you hit the enter key the javascript is ignored.
How can I call the javascript function when the enter key is pressed?
Cheers
Jemes
Code:
<SCRIPT LANGUAGE="JavaScript">
function sendtheform() {
if (document.getElementById('txtsearch').value.length < 3)
{
document.getElementById('txtsearch').focus()
alert("Please enter a search that's at least 3 characters long")
}
else{
document.getElementById('search').submit();
}
}
</SCRIPT>
<form ID="Search" name="Search" action="../search.asp" method="post" class="searchform">
<input id="txtsearch" name="txtsearch" type="text" value="<%=request.form("txtsearch")%>" size="16">
<a href="javascript: sendtheform()"><img src="../images/search_Button.jpg" border="0" align="absmiddle"></a>
</form>
|