Reputation: 279
I have a web page that whenever your in a text-field, if you hit enter, it will hit a very undesirable button. I know there are many posts out there like this, but the solutions haven't worked for me. I am using xhtml and am just wondering how I can stop the enter button from doing this, or even make it click a different button. Thank you for your time and help.
Upvotes: 1
Views: 446
Reputation: 2515
You can use javascript on your page to stop the enter button event.
<script type="text/javascript">
function stopRKey(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = stopRKey;
</script>
Upvotes: 1