<form action=”foo”>
<input type=”text” onkeypress=”return bar(event)”>
<input type=”submit”>
</form>

<script type=”text/javascript”>
function bar(evt){
var k=evt.keyCode||evt.which;
return k!=13;
}
</script>

Note however that this “enter” key behavior isn’t standard (and actually behaves differently across user agents); moreover this won’t prevent you from full server-side checking, as a client can have javascript deactivated (or even trick your javascript at runtime).

Tags: ,



Leave a Comment