0

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 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Nice! Too bad I did not figure that out myself. Thanks for the help.
-1

Have you tried

$("form").validate({ 

// put you code here

});

instead of

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.