来自jquery的.valid返回true

时间:2015-07-04 22:01:45

标签: javascript jquery validation

我想在.valid返回true时提交表单。它适用于login_form,但它会为true返回signup_form.validate方法可以正常使用,但是当表单未经过验证时,.valid会为true返回signup_form

var login_form = $( "#login_form" );
var signup_form = $( "#signup_form" );
login_form.validate();
signup_form.validate({
    rules:
    {
        signup_repeat_password:
        {
            equalTo:"#signup_password"
        }
    },
    messages:
    {
        signup_repeat_password:
        {
            equalTo:"Please repeat the password"
        }
    }
});

if ( login_form.valid())
{
    login_form.submit(
    function()
    {
        alert("Please submit login_form");
    }
    );
}

if ( signup_form.valid())
{
    signup_form.submit(
    function()
    {
        alert("Please submit signup_form");
    }
    );
}

0 个答案:

没有答案