开发者

jquery stop validation only stops after I submit twice

I am using jQuery validate and I don't want the form to validate when the user closes the form here is my code

    var obj = {};
    obj.type = "form";
    obj.formitem = $('#issue_update');
    obj.func = close_dialog
    obj.pdata = {
        func:'save_mention'
    };

    $('.submit').click(function(){
        obj.pdata.submit = $(this).val();
        $('#issue_update').submit();
    });

    $("#issue_update").validate({
        submitHandler: function() {
            run_ajax(obj);
        }
    });

and here is the html input

    <开发者_StackOverflow中文版;input type="button" id="close" class="submit cancel" value="Close" />

it seems the validation only stops when i push the close button twice

EDIT please note that it only does this when it is in an iframe RE-Edit actually does the same even stand alone


one of the demos uses a cancel button:

http://jquery.bassistance.de/validate/demo/errorcontainer-demo.html

the resetForm() method acts to remove validation from the form

var validator = $("#form2").validate({
    errorContainer: container,
    errorLabelContainer: $("ol", container),
    wrapper: 'li',
    meta: "validate"
});

$(".cancel").click(function() {
    validator.resetForm();
});


Very Strange I changed the order so that validation is setup before the click event and now it works!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜