我有这个输入文件 html 格式:
<input type="file" id="file" class="file customfile-input" name="file_upload">
我有这个提交按钮:
<input type="submit" value="Publish!" id="publish_button" name="submitPhoto" class="yellow_gradient big_button">
我想做一个 jquery 脚本,在激活提交按钮之前检查输入文件字段是否已被文件填充。 谢谢:))
最佳答案
怎么样:
$("#file").bind("change", function() {
$("#publish_button").attr("disabled", this.value.length === 0);
});
这将在文件输入中的值更改后立即重新启用 #publish_button
。
关于php - 在激活提交表单之前检查 jquery 表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4928388/