0

I have a view with Tuple model. I'm loading 4 partial views in this main view as below

1.

<div class="tab-pane fade" > 
   @Html.Partial("~/Views/Partial/_Tab1Input.cshtml", Model.Item1.Tab1Input)
</div>

2.

<div class="tab-pane fade" id="_Pump">   
  @Html.Partial("~/Views/Partial/_Tab2Input.cshtml", Model.Item1.Tab2Input)
</div>

3.

<div class="tab-pane fade" >
    @Html.Partial("~/Views/Partial/_Tab3Input.cshtml", Model.Item1.Tab3Input)  
 </div>

4.

<div class="tab-pane fade in active" id="_TDH">  
  @Html.Partial("~/Views/Partial/_Tab4Input.cshtml", Model.Item1.Tab4Input) 
</div>

I'm loading these partial views on tab click. On click of submit, only active Tab is getting validated. Means if I'm in tab 2 partial view and clicked on submit, then required field validation will happen, but tab 1 partial view's validation will be ignored, and the form is getting Posted.

Please assist me so that on click of submit, all 4 partial views required field validation should happen.

adiga
  • 34,372
  • 9
  • 61
  • 83
Ali A
  • 1
  • how are you doing the current validation? Can you provide some code? – Rajshekar Reddy Oct 13 '16 at 12:04
  • You need to re-parse the`$. validator` is you adding dynamic content –  Oct 13 '16 at 12:12
  • Possible duplicate of [Required field validations not working in JQuery Popup MVC 4](http://stackoverflow.com/questions/31768946/required-field-validations-not-working-in-jquery-popup-mvc-4) –  Oct 13 '16 at 12:13
  • @Stephen Muecke - In the main view I have input type as submit, which is validating only active tab and submitting the form. ValidationMessageFor also is definded for each input and in model also [Required(ErrorMessage = "*")] is provided. Why only active tab is getting validated i'm not getting. – Ali A Oct 14 '16 at 09:06
  • Read the duplicate! The other 3 tabs are loaded after the view has been rendered (_I'm loading these partial views on tab click_) so you need to re-parse the validator –  Oct 14 '16 at 09:36
  • Hi Stephen...I have input type as submit, and dont have button click event for this. Please assist me where I need to put these lines of code. var form = $('form'); form.data('validator', null); $.validator.unobtrusive.parse(form); Do i need to put at document.ready of other 3 tabs. Please assist – Ali A Oct 26 '16 at 09:00

0 Answers0