html,js验证表单并限制输入长度代码
<input id="username" type="text" maxlength=20 / >
同时在页面的script部分加入:
<script type="text/javascript"> $(document).ready(function(){ $("input#username").keyup(function(){ if ($("input#username").val().length >= 20){ alert('*多只能输入20个字符')///这里换成你要显示的提示语即可! } }); }); </script>
上一篇:dedecms文章选择加粗b属性,标题出现strong或b标签怎么修改?