0

I have a wizard in MVC3 that scrolls through multiple pages before reaching a confirmation page with a submit button.

My problem is, when there is a validation failure in one of the previous pages of the wizard, the issue is not visible when clicking the submit button; all the validation messages are in hidden divs.

How can I tap into the validation on clicking the submit so that I can show a dialog that says "There are one or more problems with the form submission" or something like that when validation fails?

Jeremy Holovacs
  • 22,480
  • 33
  • 117
  • 254
  • Only a suggestion, would it be easier to trigger validation per "page", not letting the user continue to the next page if there is an issue or would that model not fit? – Nope Aug 19 '12 at 16:44
  • @FrançoisWahl That makes maintaining the data across multiple redirects very unwieldy. – Jeremy Holovacs Aug 19 '12 at 16:59

1 Answers1

1

You can dynamically add each form for validation and remove it when done validating and no longer in focus. I'm on phone here so forgive the brevity as I can add more details once at computer. If all you want to do is show a message then hook into form post and check if the form is valid via form.validate() or .valid()

For more control http://www.position-absolute.com/articles/introducing-hooks-in-the-jquery-form-validation-engine-plugin/

How to hook into error of jQuery validate unobtrusive in MVC 3?

I do think this may be best done through Ajax and multiple requests and persist each stage somewhere (could use cache or db) prior to submitting for the final save.

Community
  • 1
  • 1
Adam Tuliper
  • 29,982
  • 4
  • 53
  • 71