我正在使用值文件上传器。但我想启动一个复选框,如果用户没有选中它,则禁用上传按钮。
我可以让它以常规形式工作,但不使用值,因为我认为,他使用 div 元素作为表单属性。所以我猜我把我的代码搞砸了。
在html中我有:
<form class="well">
<label>Upload a Single File</label>
<label class="checkbox">
<input id="tos" onclick="if(this.checked){this.form.qq-upload-button.disabled=false}else{this.form.qq-upload-button.disabled=true};this.blur();" checked="" value="1" name="tos" type="checkbox"> I have read and agree to the <a href="/tos">TOS</a>
</label>
<div id="file-uploader-demo1">
<noscript>
<p>Please enable JavaScript to use file uploader.</p>
<!-- or put a simple form for upload here -->
</noscript>
</div>
</form>
在 fileuploader.js (我有 valums 代码)
template: '<div class="qq-uploader">' +
'<div class="qq-upload-drop-area"><span>Drop files here to upload</span></div>' +
'<div class="qq-upload-button btn btn-primary left">Upload a file</div><span class="help-inline"> Lets Do it!</span>' +
'<ul class="qq-upload-list"></ul>' +
'</div>',
你能看出我弄错了什么吗?
本质上,如果用户没有选中该复选框,我希望禁用上传按钮。
对于常规形式,此代码有效:
<form class="well">
<label>Upload a Single File</label>
<input type="file" class="span3" placeholder="Click Here">
<span class="help-inline">Associated help text!</span>
<label class="checkbox">
<input id="tos" onclick="if(this.checked){this.form.btn.disabled=false}else{this.form.btn.disabled=true};this.blur();" checked="" value="1" name="tos" type="checkbox"> I have read and agree to the <a href="/tos">TOS</a>
</label>
<input name="btn" type="submit" class="btn btn-primary left" value="UPLOAD">
</form>