使用以下功能:
function noenter() {
return !(window.event && window.event.keyCode == 13);
}
html代码:
<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>
但它根本不起作用,它总是提交,任何想法为什么?
答案 0 :(得分:5)
<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>