/ Published in: JavaScript
This is to prevent a form from being inadvertently submitted.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> //////////////////////////////// // prototype.js is required //////////////////////////////// var tbox = '<%= txtSearch.ClientID %>'; var sbtn = '<%= btnSearch.ClientID %>'; Event.observe(window, 'load', init, false); function init(){ Event.observe(tbox, "keypress", function(e){checkEnter(e)}); } function checkEnter(e){ if (e.keyCode == 13){ $(sbtn).click(); Event.stop(e); } } </script>