0
votes

I have a view with two forms on it. Each form is marked like this:

Html.BeginForm("Details", "Forum", new { page = Model.PagedList.CurrentPage }, FormMethod.Post)

And each form has its own input button (type="button").

My problem is, when I click the button for one of the forms, the validation errors for the other form are added to the ModelState, so ModelState.IsValid == false.

How can I limit the scope of the validation to just the form I am clicking a button on?

1
That should be how it works. Are your forms nested?? If you have 1 form nested inside another form, then it's invalid html. If you need the forms to be wrapped, you'll need to use 1 form then validate only the object that you want to check or use a client side solution to submit only the object you want. - Gats

1 Answers

1
votes

Use Shared View instead to control your validations on different form.