...

View Full Version : Please click the submit button instead of using enter key



joonstar
12-10-2006, 07:03 AM
<form action='action.htm'>

<input type='text'>

<input type='submit'>

</form>
With the code above, there are two ways to make it move to action.htm.

(1) The one is clicking the buttton "submit."

(2) The other is strikes the enter key after putting your mouse on the input text box.


I like to make it (1) work, but (2) not work.


If possible, I like to make it like the follow.

if a user strikes the enter key after putting his or her mouse on the text input box, it pops an alert saying "Please click the submit button instead of using enter key."

Philip M
12-10-2006, 08:00 AM
function onKeyPress (e) {
var keycode;
if (window.event) {keycode = window.event.keyCode}
else if (e) keycode = e.which;
else return true;
if (keycode == 13) {
alert ("Please use the tab key (not the enter key) or click\nwith your mouse to move between the form fields.");
return false;
}
return true;
}
if (document.layers) document.captureEvents(Event.KEYPRESS);
document.onkeypress = onKeyPress;

Glad to see that your greedy is still up!

joonstar
12-10-2006, 11:51 AM
Glad to see that your greedy is still up!My greedy is going up and down.

Your code works fine. thank you.

felgall
12-10-2006, 06:40 PM
Just remember that the only way that people without a mouse have to "click" on something is to press the enter key so if you block that for the submit button then you stop them from being able to submit the form at all.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum