日期:2014-05-16  浏览次数:20384 次

js,的执行问题
XML code

  if (names == "") {
            alert("请输入用户名...");
            document.getElementById("IDTextBox").focus();
            return false;
        }
        else if (pass == "") {
            alert("请输入用户密码...");
            document.getElementById("NameTextBox").focus();
            return false;
        }

        else if (Str == "") {
             alert("邮箱不能为空");
             document.getElementById("eTextBox").focus();
             return false;
        }

        else if (num == "") {
            alert("电话不能为空");
            document.getElementById("numTextBox").focus();
            return false;
        }
        else if (num != "") {

            RegularExp = /^(13[0-9]|15[0|3|6|7|8|9]|18[8|9])\d{8}$/
            if (RegularExp.test(num)) {
                //return true;
            }
            else {
                alert("手机号格式不正确!应该为11位长度的数字!");
                return false;
            }

        }

        else if (Str != "") {

            RegularExp = /[a-z0-9]*@[a-z0-9]*\.[a-z0-9]+/gi
            if (RegularExp.test(Str)) {
                // return true;
            }
            else {
                alert("电子信箱格式不对!");
                return false;
            }

        }


我在bottun onclientclik ="return check()"
每次我电话号码输正确后,输入一个错误的邮箱。但是就是不弹出提示。也就是邮箱就不执行了,请高手解答

------解决方案--------------------
你用else if 执行完判断电话的代码后怎么还会执行判断邮箱的号码?
你要想都判断就用if 别用else if
else if (num != "") else if (Str != "") 这两个前面都判断过了