限制输入字数JS
<tr> <th><b>说明内容:</b><span id="content">(500字以内)</span></th> </tr> <tr> <td><input type="text" name="content" value="{$data['content']}" class="easyui-textbox" data-options="required:false,multiline:true" style="width:700px; height:350px;"></td> </tr> <script type="text/javascript"> $("input[name=content]").textbox({ onChange:function(newValue,oldValue){ if(newValue.length>5){ // $(".easyui-linkbutton").attr('disabled','false');//禁用a标签中的onclick事件 // $('.easyui-linkbutton').removeAttr('onclick');//去掉a标签中的onclick事件 $("span#content").html('输入的内容已超过5字!'); $("span#content").css('color','red'); }else{ $("span#content").html(''); return newValue; } } }) </script> —————————————————————————————————————————————————— <tr> <td> <b>说明内容:</b> <span>(限500字以内,您还可以输入字数:<input name="termLen" value="500" style=" font-size:15pt; color:red; border:0; text-align:center; width: 40px" readonly />字)</span> </td> </tr> <tr> <td colspan="2" align="center"> <textarea id="content" name="content" style="width: 90%; height: 300px; margin-top:5px;" onKeyPress="checkLen(this)" onKeyUp="checkLen(this)" onChange="checkLen(this)">{$data['content']}</textarea> </td> </tr> <script type="text/javascript"> function checkLen(term){ document.all.termLen.value=500-term.value.length; if (document.all.termLen.value<=0){ term.value=term.value.substring(0,500); } } </script> <tr> <th style="text-align:center;"><a class="easyui-linkbutton" href="JavaScript:void(0);" onclick="From_Submit('PointsSign')" data-options="iconCls:'iconfont icon-add'"><span style="font-size:14px; font-weight:600;">保存</span></a></th> </tr>