Need to ignore Enter key in Form

L

Lars Netzel

I really need to stop users from reposting the form with Enter or Return
keys. It bypasses so many onClick validations that nothign works if they use
Enter. I must force the user to CLICK on the "Save" button on my aspx page
and instead totally ignore the Enter Key.

I figured I could use this code

function EnterKeyPress(){ if (window.event.keyCode==13){ alert('No Enter
please'); return false; } }

and call that from
<body onkeydown="javascript:EnterKeyPress();">

But that doesn't work.. sure it triggers but it still makes the page
postback.

OR.. any better solution that I'm not bright enough to think of is welcomed!

please help/
Lars
 
M

masoud bayan

try this, in the function:

// cancel the default submit
event.returnValue=false;
event.cancel = true;

masoud
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top