I recently added a small Javascript routine to one of our simple search
forms. The form has two text input fields, one for a number, the other
for a name, and it has a button labeled "search". The change I added to
this form was that if a user hit enter after completing either field, it
would be just as though the user had pressed the button and the search
would happen.
Without the handler, the user's browser just causes their machine to
beep an error, because, as I'm sure you know, onSubmit doesn't default
to an enter key with more than one text field present.
I added the following to each text field definition:
onKeyPress="che ck_enter(event) "
the code called is:
function check_enter(e)
{
var char_code;
if(e && e.which) {
e = e;
char_code = e.which;
} else {
e = event;
char_code = e.keyCode;
}
if(char_code == 13)
run_acc_search( );
else
return true;
}
This is working completely, but the machine is still issuing the same
error beep when the user presses enter as though an error was made.
What have I got wrong?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Comment