Detecting ENTER key into a Textbox

see07

Regular
Joined
Apr 16, 2004
Messages
78
Location
Mexico City
Hello:
Using javascript, how can I detect into a Textbox when users press ENTER key and thus to launch a script from a link button?
I’ll appreciate your help in this subject.
A.L.
 
see07 said:
Hello:
Using javascript, how can I detect into a Textbox when users press ENTER key and thus to launch a script from a link button?
I’ll appreciate your help in this subject.
A.L.

Not sure what u mean by "detect into a textbox"...maybe put focus on the textbox via javascript..
 
Finally I got an answer:
<script language="javascript">
document.onkeypress = keyhandler;
function keyhandler(e)
{
if(document.TextBox1)
{
Key = e.which;
}
else
{
Key = window.event.keyCode;

if(Key == 13)
{
alert("<INTRO>");
}

}
}
 
b*sta*rdized from the sdk help ([mshelp=ms-help://ms.vscc.2003/MS.MSDNQTR.2003FEB.1033/DHTML/workshop/author/dhtml/reference/properties/keycode.htm]Try this link, it might work[/MShelp])


PHP:
function checkKey()
{
if (window.event.keyCode = 13) // checks whether the ENTER key 
// was pressed
{
txtOutput.value = "true"; // returns TRUE if ENTER is pressed 
// when the event fires
}
}
</SCRIPT>
</HEAD>
<BODY>
<P>Press the SHIFT key while pressing another key.<BR>
<INPUT TYPE=text NAME=txtEnterValue onkeypress="checkKey()">
<P>Indicates "true" if the shift key is used.<BR>
<INPUT TYPE=text NAME=txtOutput>
</BODY>
 
Back
Top