I need advanced HTML <input type=input ...> help.?

CWB rider

New member
Hi. I am editing code/html that is using
<input type = text name = PASSWORD_NAME size = 40 maxlength = 256 id = "passwordName" onkeydown = "checkEnter(event)">

I created the checkEnter method in some javascript that does what it says, checks for enter; if the user did hit enter, it will carry out a function, if not it will do nothing. The issue here however is that when the user hits enter, it doesnt do what my checkEnter function says, but say if i told my method to check for the tab key to be hit instead of enter, it will do what its suppose to.
So my question is this: What does <input type=text ..> do exactly when a user hits enter by default, because what ever it is, its being called befor my checkenter check. Im pretty sure it doesn't "submit" because i tried adding a "onSubmit = return null" in the <form ..> area, and it did nothing.

Thank you in advanced for helping/thinking about this issue.
-Sean
 
First off, your input code should look like this

<input type="text" name="PASSWORD_NAME" size="40" maxlength="256" id="passwordName" onkeydown="checkEnter(event)" />

And as for to see whete the user hits enter, skip using Javascript, and just do this.

<form action="checkEnter(event)">
[input code]
</form>

When the user hits enter, it will do you function.
 
Make sure you set event.keycode to some other value before returning from the function. Say, event.keycode = 0

This should work. The default action is submitting but the above change should work.

Cheers.
 
Back
Top