文本框限制字数提示

来源:互联网 发布:sql output 编辑:程序博客网 时间:2024/05/18 00:06
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>jquery text文本框限制字数或文本框提示字数</title><script type="text/javascript">function checkLength(which) {var maxChars = 10; //if(which.value.length > maxChars){alert("您出入的字数超多限制!");// 超过限制的字数了就将 文本框中的内容按规定的字数 截取which.value = which.value.substring(0,maxChars);return false;}else{var curr = maxChars - which.value.length; //250 减去 当前输入的document.getElementById("sy").innerHTML = curr.toString();return true;}}</script></head><body><form name="" id="" action="" class="Form"><textarea id="TextArea1" onkeyup="checkLength(this);" style="width:600px;height:84px"></textarea><br/><br /><button>注册登录</button><span class="wordage">剩余字数:<span id="sy" style="color:Red;">10</span></span></form></body></html>

0 0
原创粉丝点击