24 February 2011

HTML - Trigger button on enter key

The following will cause a buttons click event to fire when pressing [Enter] in a text box:
<input type="text" onkeypress="if(event.keyCode==13) document.getElementById('btnToTrigger').click()" />

No comments:

Post a Comment