我正在使用 Dropzone.js 上传文件。现在我想检查一个文件是否已填写,如果不是则取消上传。
我的 HTML 代码:
<input type="text" name="title" id="title" placeholder="Type the title of the album">
<form action="file-upload.cgi" enctype="multipart/form-data" class="dropzone" id="dropzoneform"></form>
我的 jQuery 代码:
Dropzone.autoDiscover = false;
$('.dropzone').dropzone({
acceptedFiles: 'image/jpeg',
init: function() {
this.on('sending', function() {
if ( $('#title').val().length > 0 ) {
// just start automatically the uploading
} else {
// need a code to cancel the uploading
}
});
}
});
#title
的长度为0时如何取消上传?
原文由 netdjw 发布,翻译遵循 CC BY-SA 4.0 许可协议
那这个呢