0

I have a multiple tabs in a page and each tab (lets say Menu, Edit, Tools) has a couple of text field. Each field have Required Data Annotation. I have one Save Button to save all the fields from multiple tabs. Now my problem is when I am in Menu tab and without entering anything in the text box and click Save Button I got validation summary. If I move to other tab (Edit tab) without entering anything in the textbox in the File tab and I did the same thing in the Edit tab I got validation summary of the current tab (Edit tab) only but not the other one.

How can I get validation summary from all the tabs? OR Can we validate while moving from one tab to other? FYI, Each tab is <a href = "#tab-Menu">

3
  • you could use jquery validate and manually call the validate method in each form. jqueryvalidation.org/documentation Commented Aug 5, 2013 at 20:16
  • Thank you for your quick response. I have only one form where page has multiple tabs each tabs are action reference. Commented Aug 5, 2013 at 20:19
  • A little hard to tell without seeing the markup but you could place the validation summary outside the tabs. It is certainly possible to validate upon switching tabs. You may also have to tweak the validation plugin because I believe validation is skipped for hidden elements by default and I assume the inactive tabs are hidden. Commented Aug 5, 2013 at 20:53

1 Answer 1

1

Elements on your non-active tabs are most probably hidden. Bu default after version 1.9 jquery validation does not validate hidden elements (ignore: ":hidden"). You can see discussion here: https://github.com/jzaefferer/jquery-validation/issues/279

To enable validating even hidden elements, use this code:

// This will validate all tabs at once, not just current tab.
$.validator.setDefaults({
    ignore: ""
});

More info on what you can specify is here http://jqueryvalidation.org/validate/

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.