1

I am validating a form using validate.min.js plugin. All validations are working perfectly fine but problem arises when i try to attach a file there.

The data is sent over to server but not filename / type.

Form is as below:

<form class="form cmxform" method="post" id="customForm" enctype="multipart/form-data"> 
   <div class="form-group">
        <label class="sr-only">Name</label>
        <input type="text" class="form-control" name="nam_cst" 
        id="nam_cst" placeholder="Enter Name.." required>
        <span class="help-block" style="color:red"></span>
    </div>
    <input type="file" class="form-control" name="uplod_cst" id="uplod_cst" required />    
</form>

Ajax used for this is as:

var serializedData = $(form).serialize();
$.ajax({
    url: "customFormDesign",
    type: "post",
    data: serializedData ,
    mimeType:"multipart/form-data",                         
});

With above request, name is sent as data but not file.

I tried using FORMDATA with no success and it has risk of browser compatibilties. So, i am avoiding it.

I also tried the solution here but with no success.

Any ideas please as i want to take all this in one go and one form only and that too without omiting validation plugin.

I do not want to use FORMDATA

3
  • I don't see where any of this has to do with the jQuery Validate plugin. Where is the relevant code for this? Commented Aug 13, 2015 at 18:49
  • possible duplicate of JQuery Validate input file type Commented Aug 13, 2015 at 18:51
  • @sparky.. i only copied submit handler here.. rest for validations m using jquery valaidate plugin only Commented Aug 14, 2015 at 1:47

0

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.