Home > Web Front-end > JS Tutorial > body text

Code to determine whether multiple input type=files have selected files_jquery

WBOY
Release: 2016-05-16 17:53:29
Original
1581 people have browsed it

There are multiple in the form.
When submitting the form, you need to determine that at least one of the inputs has been selected. Good document.

Copy code The code is as follows:










Use jQuery to judge:
Copy code The code is as follows:

var fileFlag = false;
$("input[name='uploadfile']").each(function(){
if($(this).val()! ="") {
fileflag = true;
return false;
}
});
if(fileFlag) {
alert("The file has been selected") ;
}

As long as fileFlag is true, you can exit the each loop and there is no need to judge the remaining input.
Use return false in each to exit the loop, use return true to end the current loop and proceed to the next loop.
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