Question

I need an ASP.NET MVC4 Ajax form with a submit button and DropDownLists that post on change.

The problem is that when I make the manual ajax posts when the DropDownList changes I want to turn off the javascript validation.

When I change selection in SelectedShiftModel this is the response, but I want this only if the submit button is clicked.

enter image description here

I made the manual ajax post this way:

$(document).ready(function () {
    $('#SelectedShiftModel').change(function () {
        var postData = $("#PostData").serialize();
        $.post("Create", postData, function (data) {
            $('#Fields').html($(data).find('#Fields').html());
        });
    });
});
Was it helpful?

Solution

This is very little code to know how to help you. But from what I see you are adding the form to the screen after the post. When the form comes back from the server it probably has the ModelState.IsValid = false. What you could do is empty the errors dictionary.

Have a look here mvc3-remove-modelstate-errors

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top