Users Pricing

forum

Home Forums jQuery: how to include validation in the ajaxForm function? – MindStick

jQuery: how to include validation in the ajaxForm function?

Anonymous User 3071 11 Mar 2013

Hi Everyone!

I have a form which needs to be validates and then submitted with ajaxForm (the form contains image and file data, so submission with .serialize() won't

work). The following are the details:

HTML:

<form id="myForm" action="..." method="post" enctype="multipart/form-data">
  ...
  <input type="file" name="image" /><br />
  <input type="file" name="file" /><br />
  ...
</form>
jQuery:

$(document).ready(function() {

  $("#myForm").ajaxForm ({

    beforeSubmit: function() {
      $("#myForm").validate({
        onkeyup:false,
        rules: {
          ...
        },
        messages: {
          ...
        },
      });
    },

    success: function(returnData) {
      $('#content').html(returnData);
    }

  });

});

Thanks in advance.


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md