I have nested form on my page.
@using (Html.BeginForm())
{
@Html.TextBoxFor(model => model.ComapnyName, new { @class = "form-control", placeholder = @Resources.Customers.ComapnyName })
@Html.ValidationMessageFor(model => model.PhoneNuComapnyNamember, "", new { @class = "text-danger" })
// other stuff
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" data-target=".modal-lg-customer-departments">
<i class="fa fa-plus"></i> Add
</button>
//bootstrap modal
@using (Ajax.BeginForm("CreateCustomersDepartments", "Customers", null, new AjaxOptions
{
HttpMethod = "Post",
UpdateTargetId = "departmentsId",
OnSuccess = "$('#departmentsModal').modal('hide')"
}))
{
@Html.TextBoxFor(model => model.Name, new { @required = "require", @class = "form-control", placeholder = Resources.Common.Name })
@Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
// other stuff
//Create departments
<input type="submit" value="@Resources.Common.Save" class="btn btn-success" name="CreateDepartments" />
}
//Create company
<input type="submit" value="@Resources.Common.Save" class="btn btn-success" name="Create" />
}
when I click submit button (Create for main form) require validator keep field from modal (depoartments add). I begin from add departments, and click submit button on modalpopup the main form keep the validator.
I tried to
How to have multiple submit buttons in your MVC forms
but page is not valid code does not come to controller. On the asp.net(web forms) I used validationGroup, how to get the same effect