验证jquery问题中的字段

时间:2016-03-29 06:44:03

标签: javascript jquery html error-handling syntax-error

我试图验证字段并且我不断获得意外令牌{但它是一个if else而且我不确定我做错了什么。任何帮助都会很棒。我只是在学习jquery。谢谢

if ((project !== "") && (example !== "") 
&& (location !== "") && (moreinfo !== "") && (email !== "") 
&& (dateTime !== "") &&(phone !== "") ((agree !== "") && (validateEmail(email))){ //here!
        $.ajax({
            url: "website url",
            data: { "entry123": allvariables above
   },
            type: "POST",
            dataType: "xml",
            statusCode: {
                0: function () {
                    window.location.replace("index.html");
                },
                200: function () {
                    window.location.replace("thanks.html");
                }
            }
        });
    } else {
        console.error(error)
        var error = error;

    }   
}

1 个答案:

答案 0 :(得分:0)

  

我正在尝试验证字段,并且我不断收到意外的令牌{

您需要在&&

之后加&&(phone !== "")

应该是

if ((project !== "") && (example !== "") 
&& (location !== "") && (moreinfo !== "") && (email !== "") 
&& (dateTime !== "") &&(phone !== "") && ((agree !== "") && (validateEmail(email))){ 
相关问题