I was looking for a way to do this, got a few scripts, but none of them is working for me.
When I hit enter in my textboxes, it shouldn\'t do anything.
I hav
If you want to prevent Enter key for specific textbox then use inline js.
<input type="text" onkeydown="return (event.keyCode!=13);"/>
<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>
http://webcheatsheet.com/javascript/disable_enter_key.php
Use global selector $('input')...if you use multiple text boxes on page the ID ('#comment') will cause problems. And when using dynamic content bind it using .live e.g.
$('input:not(textarea)').live('keypress',function(e) {
if (e.which == 13) return false;
if (e.which == 13) e.preventDefault();
});
(Disable enter for text boxes and leaves enter enabled for text areas)