0

I have a form that has seperate divs that are shown and hidden as the user progresses down the page.

The submit is only down at the bottom of the page.

Each div has a button that calls a javascript function. In the function I want to only validate the elements within that div.

I have tried the validate.element("#txtUserName") and that does validate the specific elements, but then does not show the validation summary.

I have also tried $("#frm").validate().form(), but that validated everything on the form - so divs the user hadn't even reached yet.

Thanks.

Stu Harper
  • 721
  • 2
  • 9
  • 22

1 Answers1

3

Use $(element).validate(options);, in this way:

function validateCallback(){
    //do something
}
$("#txtUserName").validate({onValidate:validateCallback})

See this page for a small overview; See this page for a detailled documentation, including examples.

Rob W
  • 341,306
  • 83
  • 791
  • 678
  • Thanks Rob. But using jquery.validate.js, how do I actually then display the ValidationSummary? I should have said that I am using asp.net MVC, so the MVC ValidationSummary. – Stu Harper Sep 15 '11 at 10:33
  • I'm not familiar with ASP.net+MVC. I've added an additional resource, with a more detailled explanation of the JQuery validation plugin. If you still have questions, please explain how ASP.net adds a validation summary to the page, with respect to the JQuery validation approach. – Rob W Sep 15 '11 at 12:15