Link to home
Start Free TrialLog in
Avatar of PSV
PSV

asked on

Enter key to respond in a text box

I want a text box which is password type should be able to respond an enter key i.e; on pressing the enter key another page needs to be called. I am also not able to trap the ASCII values  of keys pressed from the keyboard in Javascript.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rafistern
rafistern

If you make a form with only one button then an <Enter> will submit the form:

<form action="whatever">
<input type="password" name="password" size=10>
<input type="submit" value="OK">
</form>
My solution will work in any browser, although it wasn't really what you asked.
PS: A form with a single text/password field will submit with the enter in most browsers without the JavaScript:
<FORM...>
<INPUT TYPE="PASSWORD">
</FORM>

but IE3 (last time I looked) will not submit the form if there is one more entry field on the page (even if it is not in the same form)

All the 'normal' keys are passed in e.which or window.event.keyCode and can be trapped. The 13 is the enter key
Rafi: Stop submitting at the same time as me ;-)

Michel
Michel's last comment seems to me to be an optimal solution if it works. However I would prefer to have the button there for people who like clicking buttons - it makes the user interface more intuitive.

(I submit to the same threads as you because there seem not be many active experts on European timezones. Whatever is happening in the morning on our side of the world is the middle of the night in the States.)