hi guys i am 开发者_开发技巧trying to disable enter key from submitting the form in a textarea
using the following function:
function noenter() {
return !(window.event && window.event.keyCode == 13);
}
html code:
<form:form modelAttribute="myObject" method="post" action="${myUrl}">
<form:textarea path="name" class="new_obj submits_on_return" cols="40" rows="3" onkeypress="return noenter()"></form:textarea>
but it doesn't work at all, it always submits, any ideas why ?
<script language="JavaScript">
function disableEnterKey(e)
{
var key;
if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox
if(key == 13)
return false;
else
return true;
}
</script>
精彩评论