Skip to content Skip to sidebar Skip to footer

Reset Required Fields - Jquery

I have some fields that I'm requiring depending on which button is clicked. The behavior I'm seeing though is not what I would expect nor desire. When I click one of the buttons,

Solution 1:

Try reseting the form before setting new required items: http://docs.jquery.com/Plugins/Validation/Validator/resetForm

Solution 2:

I'm not 100% sure but try removing the rules first before you apply new ones

functionmakeAllRequired() {
    $("#SomeForm").rules("remove");
    $("#SomeForm").validate({
        rules: {
            StartDate: {
                required: true,
                date: true
            },
            Name: {
                required: true
            }

        },
        errorElement: "div"
    });
}

functionmakeSomeRequired() {
    $("#SomeForm").rules("remove");
    $("#SomeForm").validate({
        rules: {
            StartDate: {
                required: true,
                date: true
            }
        },
        errorElement: "div"
    });
}

Post a Comment for "Reset Required Fields - Jquery"