button focus and pressing enter

P

Philip Townsend

Can anybody tell me how I can disable the enter (keyboard) button from
being able to submit a form? In other words, force the user to click a
button with the mouse?
 
K

karl

Heres a simple way, not the best way maybe.

<script language="javascript">
function keyPress()
{
if (event.keyCode == 13)
{
event.returnValue = false;
}
}
</script>


<body onkeypress="KeyPress();">
or you can specify each textbox, etc.. by placing code like this in the
Page_Load Event
this.tbCode.Attributes.Add("onkeypress", "keyPress();");

the same technique can be used to fire an event like save, or search
function keyPress()
{
if (event.keyCode == 13)
{
event.returnValue = false;
document.getElementById("btnDoSearch").click();
}
}

Karl
 

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,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top