


Code to determine whether multiple input type=files have selected files_jquery
May 16, 2016 pm 05:53 PMThere are multiple <input type="file" name="uploadfile" contentEditable="false" style="width:80%"> in the form.
When submitting the form, you need to determine that at least one of the inputs has been selected. Good document.
<input type="file" name="uploadfile " contentEditable="false" style="width:80%"><br>
<input type="file" name="uploadfile" contentEditable="false" style="width:80%"> ;<br>
<input type="file" name="uploadfile" contentEditable="false" style="width:80%"><br>
<input type="file " name="uploadfile" contentEditable="false" style="width:80%"><br>
<input type="file" name="uploadfile" contentEditable="false" style="width :80%">
Use jQuery to judge:
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.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Hongmeng native application random poetry

Use java's File.length() function to get the size of the file

Rename files using java's File.renameTo() function

Use java's File.getParentFile() function to get the parent directory of the file

Use java's File.getParent() function to get the parent path of the file

How to delete a file or directory using File.delete() method in Java?

WebView File Domain Origin Policy Bypass Vulnerability Example Analysis
