开发者

Cannot disable enter key on a textarea

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜