gpt4 book ai didi

php - 在激活提交表单之前检查 jquery 表单?

转载 作者:行者123 更新时间:2023-11-28 12:26:34 27 4
gpt4 key购买 nike

我有这个输入文件 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

工作示例:http://jsfiddle.net/andrewwhitaker/hUDUC/1/

关于php - 在激活提交表单之前检查 jquery 表单?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4928388/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com