0

I am trying to validate a HTML file upload using jQuery Validate plugin,

My html form is,

<form id="formid" action="welcome/test_up" method="post" enctype="multipart/form-data">
<input type="file" name="myfile[]" id="myfile" multiple>
<input type="submit" name="submit" id="submit" value="submit"/>

And I'm using Jquery validation plugin as,

$('#formid').validate({
    rules: { 
       inputimage: { required: true, accept: "png|jpe?g|gif"  }
    },
    messages: { inputimage: "File must be JPG, GIF or PNG" }
});

But unfortunately it's not working,

It's working if I use name="myfile" but not when I use name="myfile[]"

Any idea to solve this ?

Jenz
  • 8,280
  • 7
  • 44
  • 77
Vinoth Pandiyan
  • 241
  • 7
  • 19

1 Answers1

0

try to set your rule in input tag become

<input type="file" name="myfile[]" id="myfile" accept="png|jpe?g|gif" multiple>

so your js only

$('#formid').validate();