forum

Home / DeveloperSection / Forums / jQuery: how to include validation in the ajaxForm function?

jQuery: how to include validation in the ajaxForm function?

Anonymous User266611-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.


Updated on 11-Mar-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By