Home >Web Front-end >JS Tutorial >Example of jQuery judging that multiple input files cannot be empty_jquery

Example of jQuery judging that multiple input files cannot be empty_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 15:53:291516browse

For example, if there are two inputs for image upload, images must be uploaded:

html

Copy code The code is as follows:

Select file 1:
Select file 2:

js

Copy code The code is as follows:

if($(".myfile").length == 2){

$(".myfile").each(function(){

 if($(this).val() == "") {

alert("Please upload pictures!");
flag = 0;
      }
});

}else if($(".myfile").length !=2 ){
 
alert("No less than 2 pictures!");
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn