-1

How do I get the jQuery validation plugin to work on a form that's generated using ajax after the page loads? I have a from on my page that's returned from an ajax call, and the jquery validation plugin will not validate that form when I do like below. Any ideas on how to do this? When I submit the form, it submits the usual way, not using ajax

It's currently setup like this, where <form id="newRequest"> is generated after a user clicks a link on the page.

However, the plugin will not validate #newRequest

$("#newRequest").validate({
    rules: {

    },
    messages: {

    },

    submitHandler: function() {
    $.ajax({

    //etc
danmullen
  • 2,556
  • 3
  • 20
  • 28
jmenezes
  • 1,888
  • 6
  • 28
  • 44

1 Answers1

-1

Dynamic elements are treated differently by the jQuery validation. You need to parse the form in validation flow like this,

$.validator.unobtrusive.parse("#newRequest");

This has been answered here as well.

Nicely tutorial.

Community
  • 1
  • 1
Rohit416
  • 3,416
  • 3
  • 24
  • 41