第一个控制只能输入数字  5-10位,超过就提示
第二个2个输入框同时输入一个密码,如果2个输入框密码不一样就提示
第三个是这上面3个输入框必须输入,否则提示
望给个答案,谢谢。

解决方案 »

  1.   

    第一题 加一个onkeydown事件
    第二题在第二个输入框中加入onmouseout事件
    第三题 在提交的时候加上非空的判断吧。。
      

  2.   

    楼主的问题提的不够清楚,都没说明是在什么时候验证,验证的方法其实很简单,我这里提供一下,至于什么时候调用,用什么事件调用就看楼主自己了
    1.假设第一个输入的ID为t1 即<input type='text' id='t1' />
    function checkNum(){
       var t1=document.getElementById('t1').value;
       if(isNaN(t1)){
    alert("请输入数字");
    document.getElementById('t1').focus();
       }else{
    if(t1.length<5 || t1.length>10){
    alert("请输入5-10位的数字");
    document.getElementById('t1').focus();
    }
       }
    }2.假设第一个密码框为p1 ,第二个为p2,即
    function  checkPassWord(){
    var p1=document.getElementById('p1').value;
    var p2=document.getElementById('p2').value;
    if(p1!=p2){
    alert("两次输入的密码必须一致");
    document.getElementById('p2').focus();
    }
    }
    3.function checkSubmit(){
    var t1=document.getElementById('t1').value;
    var p1=document.getElementById('p1').value;
    var p2=document.getElementById('p2').value;
    if(t1=""){
    alert("请输入完整的资料")
    document.getElementById('t1').focus();
    }
    if(p1=""){
    alert("请输入完整的资料")
    document.getElementById('p1').focus();
    }
    if(p2=""){
    alert("请输入完整的资料")
    document.getElementById('p2').focus();
    }
    }