This article describes js text box to enter the word limit, dynamic display of words you can enter the number of words can also enter the prompt, a friend in need can refer to.
代码如下:
<input name="title" type="text" size="50" value="{$p.title}" maxlength="15" onkeyup="javascript:setShowLength(this, 15, 'cost_tpl_title_length');">
<Span class = "red" id = "cost_tpl_title_length"> can also enter words 15 </ span>
js code as follows:
function setShowLength(obj, maxlength, id) {
var rem = maxlength - obj.value.length;
var wid = id;
if (rem < 0){
rem = 0;
}
document.getElementById(wid).innerHTML = "还可以输入" + rem + "字数";
}