可以帮我写下吗?要求必须能有FOCUS回焦点功能

解决方案 »

  1.   

    <input type="text" value="" name="num1" id="num1" />
    <input type="text" value="" name="num2" id="num2" />
    <input type="button" value="测试" onclick="check()" />
    <script> function check(){
    var t1=/^\w{1,20}$/,t2=/^\d{1,30}$/
        if(t1.test(document.getElementById("num1").value)==""){
            alert('不行11111');
            document.getElementById("num1").focus()
            return false;
        }
        if(t2.test(document.getElementById("num2").value)==""){
            alert('不行22222222')
            document.getElementById("num2").focus()
            return false;
        }
    }
    </script>