复制代码 代码如下:
<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">还可以输入15字数</span>
js:
复制代码 代码如下:
function setShowLength(obj, maxlength, id)
{
var rem = maxlength - obj.value.length;
var wid = id;
if (rem < 0){
rem = 0;
}
document.getElementById(wid).innerHTML = "还可以输入" + rem + "字数";
}
时间: 2024-10-27 20:48:28