Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to ignore onkeypress event in asp.net

Status
Not open for further replies.

s2001

Programmer
Dec 7, 2001
132
US
I have a log off button on the top a web form. Whenever a user hits the enter key on the form, they get logged off.
I want to make sure that the log off button ignores the enter key. Can any body help?

TIA


Thanks,
MB
 
Use javascript to capture the keycode 13 and cancel it.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
thanks for the reply.
i tried this..but does'nt work

<script language="javascript">
function submitLogOff() {
if(event.keyCode == 13){
event.keyCode=0;
return false;
}
}

</script>

Thanks,
MB
 
Try this example:
Code:
// IE
document.onkeydown = function () {
if (window.event && window.event.keyCode==13)
return false;
};


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
thanks for the help. This code disables all the enter key event on the document. I have textboxes that should fire on the enter key.

I feel that since the logoff button is on the top of the form and since it is the first control on the form it has the focus...

Thanks,
MB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top