Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

327
Views
Validate multiple file extension and size jQuery validation. only1 file size checking but add 2 or 3 it will not checking the file size

$.validator.addMethod("filesize", function(value, element, param) { return this.optional(element) || (element.files[0].size <= param * 1000000) }, 'File size must be less than {0} MB');

$().ready(function() { $("#add-images").validate({ rules: { "Attachemnts[]": { accept: "audio/,video/,image/*,.pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document", maxfiles: 3, filesize: 2 }, }, messages: { "Attachemnts[]": { accept: "Only few formats are accepted(eg: audio,video,image and pdf)", filesize: "File size must be less than 2 MB" }, } }); });

$.validator.addMethod("filesize", function(value, element, param) {
  return this.optional(element) || (element.files[0].size <= param * 1000000)
}, 'File size must be less than {0} MB');

$().ready(function() {
  $("#add-images").validate({
    rules: {
      "Attachemnts[]": {
        accept: "audio/*,video/*,image/*,.pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document",
        maxfiles: 3,
        filesize: 2
      },
    },
    messages: {
      "Attachemnts[]": {
        accept: "Only few formats are accepted(eg: audio,video,image and pdf)",
        filesize: "File size must be less than 2 MB"
      },
    }
  });
});
<form name="add-pkg" id="add-images" method="POST" enctype="multipart/form-data">
  <input name="Attachemnts[]" id="Attachemnts[]" type="file" multiple accept="audio/*,video/*,image/*,.pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
  <div class="form-group">
    <input type="submit" name="AddImages" value="Add Images" />
  </div>
</form>

<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.3/jquery.validate.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery-validation@1.19.3/dist/additional-methods.min.js"></script>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!