<script type="text/javascript" src="${ctx}/static/js/jquery.maxlength-min.js"></script>
.testbox {
width: 100%;
min-height: 8em;
max-height:12em;
margin-top:1em;
outline: 0;
border: 1px solid #d0d0d0;
font-size: 12px;
word-break:break-all;
dispaly: block;
overflow-x: hidden;
overflow-y: auto;
resize: none;
border-radius: 7px;
}
.tip
{
color: #00A8C6;
padding-left:2px;
text-align: right;
}
<div>
<textarea id="contentValue" maxlength="100" class="testbox"></textarea>
</div>
$(document).ready(function (e) {
$('#contentValue').maxlength({
maxCharacters: 100, //限制字符数
status: true, //是否开启字数提示
statusClass: 'tip', //提示框的样式
notificationClass: 'notification', //超出限制时文本框的样式
showAlert: false, //超出限制时是否弹出提示框
alertText: '最多只能输入20个字符', //超出限制时弹出框的提示文字
slider:false //提示幻灯效果
});
});
$("#contentValue").keydown( function(e) {
var key = window.event?e.keyCode:e.which;
if(key.toString() == "13"){
return false;
}
});