动态计算还能够输入多少字节的表单

<script>
function chkValid(){
if(event.keyCode >= 48 || event.keyCode <=57 || event.keyCode >= 65 || event.keyCode <= 90 || event.keyCode>=97 || event.keyCode<=122)
event.returnValue=true;
}

function textCounter(field,countfield,maxChr,icount){
if (field.value.length > maxChr )
field.value = field.value.substring(0,maxChr);
else
countfield.value = maxChr - field.value.length;
icount.value = field.value.length;
}
</script>
<form action="" method="post" name="form1" id="form1" onSubmit="return checktext()" onKeyDown="if(event.ctrlKey && event.keycode==13)document.form1.submit();">
<textarea name="PLContent" onKeyDown="textCounter(this,this.form.chrSX,200,this.form.chrCount);" onKeyUp="textCounter(this,this.form.chrSX,200,this.form.chrCount);"></textarea>
&nbsp;
共输入:<input type="text" readonly name="chrCount" id="chrCount" style='width:25px;' value="0" class="count" disabled>&nbsp;
还剩:<input id="chxSX" name="chrSX" style='width:25px;' readonly type="text" value="200" class="sx" disabled>(最多可以输入200个字符)
<input type="hidden" name="ID" value="">
<input type="submit" name="submit1" value="提交" id="submit1">
</form>

 
300*300
  • 没有相关文章
  • 没有评论
 文章首页关于迷茫时代关于我写意人生
版权所有:迷茫时代 All rights reserved   
执行时间:0.00358 秒