gpt4 book ai didi

javascript - 当还有东西要加载时停止表单提交

转载 作者:行者123 更新时间:2023-11-30 12:38:24 25 4
gpt4 key购买 nike

我写了一段代码。我就是想看看有没有效果!!!考虑并行下载。我正在禁用按钮,然后在处理表单的 script 标记之后启用它。我想确保用户在加载必要文件之前不提交表单,例如 "checkform.js"

<input type="text"><br>
<input type="submit" value="submit" id="submit">
<script>
document.getElementById('submit').setAttribute('disabled','disabled');
</script>

<script src="checkform.js"></script>
<script>
document.getElementById('submit').removeAttribute('disabled');
</script>

最佳答案

试试这个:1.将disable放在submit btn的一个属性中。2.在checkform脚本标签中添加onload属性。

<input type="text"><br>
<input type="submit" value="submit" id="submit" disabled="disabled">

<script>
function checkformLoaded() {
document.getElementById('submit').removeAttribute('disabled');
// do whatever else you want after the script is loaded!
}
</script>

<script src="checkform.js" onload="checkformLoaded"></script>

关于javascript - 当还有东西要加载时停止表单提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25342454/

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