输入框输入联动

当输入序号并且是10位数的序号后才能输入姓名

<ul>
    <li>
        <span>户号</span >
        <input id = "testNo" type = "number" placeholder = "请输入" >
    </li>
    <li>
        <span>姓名</span >
        <input id = "testName" type = "text" placeholder = "请输入" >
    </li>
</ul>

  

 $("#testNo").focus();
    $("#testNo").blur(function () {
        if ($(this).val() != "") {
            if (!(/^[1-9]\d{9}$/.test($(this).val()))) {
                $("#testName").val("");
                $("#testNo").focus();
                console.log("客户编号10位数字,请重填");
            }
        } else {
            $("#testNo").focus();
            console.log("请优先输入客户编号");
        }
    });

  

posted @ 2018-04-04 16:26  章晓鱼  阅读(927)  评论(0)    收藏  举报