0
votes

There are multiple forms on one page. in my code PHP captures which form is being submitted by submit button name like this:

if (!empty($_POST['submit-btn-name']))

It all works well without jquery validation. However when I try to validate each form with JQuery form validation plugin, the plugin's submit handler doesn't let PHP see which form has been submitted.

$("#profileupdate,#contactform").each(function(){

   $(this).validate({
      errorPlacement: function (error, element) { },
      onkeyup: false,
      submitHandler: function(form) {
           form.submit();
      }
   });
});
2

2 Answers

1
votes

Assuming the submit-btn-name is the value of a particular button, I believe that the value is submitted by the browser as a result of the button being clicked. Most likely you are not getting this once you call form.submit() directly. It may help if you instead move the value into a hidden form field rather than rely on the button value being passed. Correct me if my assumptions are wrong, of course.

-1
votes

Have you tried

$("form").validate({ 

// put you code here

});

instead of

$("#profileupdate,#contactform").each(function(){

   $(this).validate({
      // put you code here
   });
});