There are multiple <input type = "file" name = "uploadfile" contentEditable = "false" style = "width: 80%">,
When submitting a form, you must determine that at least one input file has been selected.
Copy codeThe Code is as follows:
<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:
Copy codeThe Code is as follows:
Var fileFlag = false;
$ ("Input [name = 'uploadfile']"). each (function (){
If ($ (this). val ()! = ""){
Fileflag = true;
Return false;
}
});
If (fileFlag ){
Alert ("selected files already exist ");
}
As long as the fileFlag is true, you can exit the each loop and do not need to judge the remaining input.
Use return false in each to exit the loop. Use return true to end the current loop and perform the next loop.