<form name='form1'... onsubmit='check(this)'>
<input name='test' type='text'>
....
</form>
function check(form){
obj = form.test;
if(obj.length>10){
alert('长度超过10');
}
}

解决方案 »

  1.   


    修正一点:
    <form name='form1'... onsubmit='return check(this)'>
    <input name='test' type='text'>
    ....
    </form>
    function check(form){
    obj = form.test;
    if(obj.length>10){
    alert('长度超过10');
    return false;
    }
    return true;
    }
      

  2.   

    <input type="text" name="Nums" size="20" maxlength=20>
                                             ^^^^^^^^^
      

  3.   

    <input type="text" name="Nums" maxlength=5>
      

  4.   

    maxlength有个缺陷,设置了maxlength=6,可输入6个汉字,而不是3个汉字,谁有解决方法