jquery validation problem

1

I'm using a form to populate items in a list dynamically. I cleaned the form fields by inserting the items from the list into adding items.

Problem:

When I submit it to write, Razor @Html.ValidationMessageFor help intervenes not allowing the submit, because it is necessary to write the list items of the parent object.

Solution to be found:

When submitting the form. Arrow the form field with required false.

I was kind of wanting to manipulate the library $("#form").validate();

I was researching about this function, but I still managed to get it to work.

Code:

$(".btnGravarEmpenho").on("click", function () {
    $("#formConvenio").submit();
});

//estava testando essa função
$("#formConvenio").validate({
    rules: {
        input: {
            required: false
        }
    },
    messages: {
        input: {
            required: "fsfafafa"
        }
    },
    ignore: "",
    errorClass: 'fieldError',
    onkeyup: false,
    onblur: false,
    errorElement: 'label',
    submitHandler: function () {
        alert("alert");
    }
});

Of course, the properties that have the validation anotations will reflect in the views and controller. But I still need validation when inserting the item but not submitting. Because what the valley is the list of the object.

    
asked by anonymous 22.12.2014 / 15:25

0 answers