验证状态在JQuery Validation Engine插件中返回false

时间:2015-12-29 14:21:39

标签: jquery html5 validation

我正在使用jQuery验证插件(jQuery-Validation-Engine)来检查电子邮件是否已被采用? 它已成功验证,但我收到验证状态为“false”当电子邮件字段显示消息“此用户名可用”时。这是错误信息吗? 以下是我的示例代码: HTML代码:

<form method="POST" name="register_form" id="registerForm" >                
    <div class="register">
        <div class="block3">
            <input type="text" placeholder="First Name" class="username1 validate[required]" name="reg_name" id="name" >

            <input type="text" placeholder="Email ID" class="username1 validate[required,custom[email],ajax[ajaxUserCallUserEmail]]" name="emailr" id="emailr" >
        </div>

        <div class="block4">
            <input type="text" placeholder="Last Name" class="username2 validate[required]" name="lastname" id="lastname" >

            <input type="text" placeholder="Phone Number" class="username2 validate[required,minSize[10],maxSize[10],custom[phone]]" id="phonenumberr" name="phonenumberr" />
        </div>

        <div class="register_button">
            <div class="regi_button"><input type="button" id="register" name="register" value="" /></div>
        </div>
    </div>
</form>

JavaScript代码:

$("#register").click(function(){
    var status = $("#registerForm").validationEngine('validate');
    alert("status== "+status); //Return false

    if($("#registerForm").validationEngine('validate')) 
    {
        alert("hello");

        var fname = $("#name").val();
        var lname = $("#lastname").val();
        var email = $("#emailr").val();
        var phone = $("#phonenumberr").val();

        $.ajax({
            type: "POST",
            url: "ajaxCheckUser.php",
            data: {"fname":fname, "lname":lname, "email":email, "phone":phone},
            success: function(data){
                alert("data== "+data);

                if(data!=0)
                {
                    //window.location.href=data;
                }
                else
                {
                    //$("#errorMessage").removeClass("hide");
                }
            }
        })
    }
});

0 个答案:

没有答案