js限制文本框输入字数
//js代码
<script type="text/javascript">
function checkLen(term){
document.all.termLen.value=30-term.value.length;
if (document.all.termLen.value<=0){ t
erm.value=term.value.substring(0,30); } }
</script>
//html代码
<table border="0" width="98%">
<tr>
<td colspan="2" align="center"> <textarea id="txtLookReason" style="width: 99%; height: 100px; margin-top:5px;" onKeyPress="checkLen(this)" onKeyUp="checkLen(this)" onChange="checkLen(this)"></textarea> </td></tr>
</table>
<span class="color_red">(限30字以内,您还可以输入<input name="termLen" value="30" style="background-color:#FFFFFF; font-size:9pt; color:#FF3333; border:0; text-align:right" size="3" readonly /> 字)</span>