Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i did enter key work as tab in web project it works fine as a press enter key it shifted focus to next control but when focus comes to Submit button i want to change it and if i pressed enter key then it must submit page or form
i did it like
XML
<body onunload="if(screenTop >9999) windows.location.href('LoginPage.aspx');" onkeydown="javascript:if(event.keyCode==13){event. keyCode=9;}">

in master page.
plz help me.
Posted
Updated 19-Apr-12 1:31am
v2
Comments
ZurdoDev 17-Apr-12 8:03am    
What is the question?
mu-kul 19-Apr-12 7:28am    
i'm using master page in that i write above code to work enter key as tab as a result when i press enter focus shift to next control ok but now when focus comes to Submit button of any page(Form) i want to change it back to enter key by which it get submited.
ZurdoDev 19-Apr-12 7:41am    
try checking event.srcElement
bbirajdar 17-Apr-12 8:52am    
Unclear...
mu-kul 19-Apr-12 7:28am    
i'm using master page in that i write above code to work enter key as tab as a result when i press enter focus shift to next control ok but now when focus comes to Submit button of any page(Form) i want to change it back to enter key by which it get submited.

Though what you are doing is not suggestible, yet if you need the flow as you asked, did you try to attach a onkeydown event on your submit button that will override the onkeydown defined earlier? All you need is to override and cancel the bubbling of event. Submit button will work as its normal behavior.

Try:
HTML
<input type="submit" onkeydown="javascript:event.cancelBubble=true;"/>
 
Share this answer
 
As stated, you should not do this. Having a button that does one thing sometimes and another thing at other times is very confusing to users. A single button should perform one function only.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900