Multiple file upload extension validation using jQuery Validate

Today, We want to share with you Multiple file upload extension validation using jQuery Validate.In this post we will show you Validate multiple image field using jQuery, hear for jquery validations for file upload extension and size we will give you demo and example for implement.In this post, we will learn about How to check file size when select multiples file validations using Jquery? with an example.

Multiple file upload extension validation using jQuery Validate

There are the Following The simple About Multiples files upload extension validations using jQuery Validate Full Information With Example and jquery validation input file source code.

As I will cover this Post with live Working example to develop jQuery Validate plugin for multiples files upload validations, so the some image validations in jquery for this example is following below code for file size validation in jquery for upload.

Read Also:  file upload validation in jquery

jquery validations for file upload extension and size

jquery file upload validation example

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="//ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>

<form id="createpreview"><input multiple="multiple" name="filesimg_src[]" required="" type="file" />
<input type="submit" /></form><a title="pakainfo" href="https://www.pakainfo.com/" target="_blank" rel="noopener noreferrer">Free Download Example - Pakainfo.com</a>
<script>
jQuery.validator.addMethod("extension", function(value, element, param) {
	param = typeof param === "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
	return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
}, jQuery.format("Please enter a value Like (jpg, jpeg, png, PDF, doc, docx) a valid extension."));

$.validator.addMethod('maxfilesize', function(value, element, param) {
   var length = ( element.files.length );

    var fileSize = 0;

           if (length > 0) {
               for (var i = 0; i < length; i++) {
                   fileSize = element.files[i].size; // get file size
                    // console.log("if" +length);

                        fileSize = fileSize / 1024; //file size in Kb
                        fileSize = fileSize / 1024; //file size in Mb

                     return this.optional( element ) || fileSize <= param;
               }

            }
            else
            {
                return this.optional( element ) || fileSize <= param;
                    //console.log("else" +length);
            }
});

$('#createpreview').validate({
		rules: {
				"filesimg_src[]": {
				             required: true,
				             maxfilesize : 5,
				             extension: "jpg|jpeg|png|PDF|doc|docx",
				             filesize: 10971520,  
				          }
		}, messages: {
			    'filesimg_src[]':{
			      	 maxfilesize : "File size must not be more than 10 MB."
			    }
		}
});
</script>


Validate multiple image field using jQuery

Read Also:  image validation in jquery

jquery form validation for file upload with jquery validate file type before upload & jquery validate file size before upload or jquery validation input file Examples

jQuery.validator.addMethod("extension", function(value, element, param) {
param = typeof param === "string" ? param.replace(/,/g, '|') : "png|jpe?g|gif";
return this.optional(element) || value.match(new RegExp(".(" + param + ")$", "i"));
}, jQuery.format("Please enter a value with a valid extension."));

More jQuery Validations methods:http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.0/additional-methods.js

jQuery Validate plugin for multiple file upload validations
Angular 6 CRUD Operations Application Tutorials

Read :

Read Also:  PHP Laravel Redirect with Query String Example

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

Related Search : jquery validate extension multiple images upload,How to check file size when select multiple file validations using Jquery?,Multiple File Upload Input,Validate multiple image field using jQuery,jQuery validations for file type extension,jquery validations for image upload in php,jquery validations for file upload extension and size,multiple file upload validations in javascript,image validation in jquery,multiple image upload validations in javascript,jquery validate csv file upload,image validations in javascript,jquery vali dation engine file upload

I hope you get an idea about Multiples files upload extensions validations using jQuery Validate.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  How to add custom jquery image validation?
  2. Read Also:  how can you open a link in a new tab/browser window in html?
  3. Read Also:  file upload size limit validation in javascript
  4. Read Also:  jQuery Validate Multiple File Image Upload validation
  5. Read Also:  jQuery CDN Link Cheat Sheet Download
  6. Read Also:  PHP Include and Require commands
  7. Read Also:  Jquery File Upload Size validation Example
  8. Read Also:  Table with ng-repeat using Angular Example
  9. Read Also:  Top 10 Angular2 Interview Questions and Answers
  10. Read Also:  Simple bootstrap product slider responsive
CLOSEX