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

WBOY
Release: 2016-05-16 15:53:29
Original
1506 people have browsed it

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!");
}

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template