Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery validation form with ajax loaded form

Tags:

jquery

ajax

I have a form with jquery validation .After submitting the form I load the same form through Ajax . My problem is jquery validation is not working for ajax loaded form . I have tried some answers of the stack overflow but unfortunate not working .

Thanks Az

like image 557
jai Avatar asked May 16 '13 04:05

jai


2 Answers

use on function. .

example:

 $(document.body).on('click', '.submitBtn', function(){
       $("#form").validate({
          submitHandler: function() {
              // do anything
         } 
    });
 });
like image 51
shilpi Singh Avatar answered Sep 22 '22 03:09

shilpi Singh


From the description it looks like the new DOM elements are giving you the problem. This is a very common problem. What you need to do is - if you validation is running on a button's click function then change that from .click to .live function. = http://api.jquery.com/live/

This function also validates the new DOM elements. The click function will only work on those elements which were present in the initial DOM.

If you are still having problem, share the code.

like image 23
Amitav Roy Avatar answered Sep 21 '22 03:09

Amitav Roy