天天看點

html5 div maxlength,jquery maxlength使用說明

CSS:

body

{

line-height: 1.5;

font: 14px/1.5 arial,serif;

color: #AAA;

}

.notification

{

border: 3px solid #D55B5B;

background-color: #FFCDCD;

padding: 5px;

}

.tip

{

color: #00A8C6;

padding-left:2px;

}

JavaScript:

$(document).ready(function (e) {

$('#txtContent').maxlength(

{

maxCharacters: 20, //限制字元數

status: true, //是否開啟字數提示

statusClass: 'tip', //提示框的樣式

notificationClass: 'notification', //超出限制時文本框的樣式

showAlert: false, //超出限制時是否彈出提示框

alertText: '最多隻能輸入20個字元', //超出限制時彈出框的提示文字

slider:true //提示幻燈效果

}

);

});

html:

效果如下: