[英]Javascript to limit the number of file uploaded input file
I want to limit the number of files uploaded to 3. Im new on this, so please anyone can help? 我想限制上传到3的文件数量。我是新的,所以请任何人都可以帮忙吗?
Here my code: 这是我的代码:
$('#fileinput').change(function(){ if(this.files.length>3) alert('to many files') });
<input id="fileinput" type="file" name="fileUpload" multiple="multiple"/>
What you have generally works in a browser supporting the files apis. 你通常在支持文件apis的浏览器中工作。 Here's your code, made to work:
这是你的代码,工作:
$(document).ready(function() {
$('#fileinput').change(function() {
if (this.files.length > 3)
alert('to many files')
});
});
https://jsfiddle.net/6vw0maLb/2/ https://jsfiddle.net/6vw0maLb/2/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.