Javascript 更改为在Firefox中加载的按钮不起作用
我创建了一个简单的按钮,单击后可以更改为加载。应该验证表单。代码如下所示:Javascript 更改为在Firefox中加载的按钮不起作用,javascript,html,firefox,Javascript,Html,Firefox,我创建了一个简单的按钮,单击后可以更改为加载。应该验证表单。代码如下所示: <button type="submit" onClick="this.form.submit(); this.disabled=true; this.value='acceptAction'; buttonSubmit();" class="btn btn-block btn-primary" name="acceptAction"> <span style="display:block;
<button type="submit" onClick="this.form.submit(); this.disabled=true; this.value='acceptAction'; buttonSubmit();" class="btn btn-block btn-primary" name="acceptAction">
<span style="display:block;" id="buttonText">
Next step <i class="fas fa-chevron-right ml-2"></i>
</span>
<span style="display:none;" id="buttonSipner">
Loading...
<div class="spinner-border spinner-grow-sm ml-2" role="status">
<span class="sr-only">Loading...</span>
</div>
</span>
</button>
<!-- JS Page -->
<script>
function buttonSubmit() {
document.getElementById('buttonText').style.display = 'none';
document.getElementById('buttonSipner').style.display = 'block';
}
</script>
下一步
加载。。。
加载。。。
函数按钮提交(){
document.getElementById('buttonText').style.display='none';
document.getElementById('buttonSipner')。style.display='block';
}
问题是,当在Firefox上单击该按钮时,如果表单没有填写,它将被锁定,无法执行更多操作。这不仅适用于Firefox(73.0.1 x64 en-US)。其他浏览器将检查表单并解锁按钮
要使表单正常工作,您必须更改“提交到”按钮 效果很好:
<button type="button" [...] >Submit</button>
提交
不起作用:
<button type="submit" [...] >Submit</button>
提交
只要求在Firefox上使用。什么是“表单未填写”?您的表单验证代码在哪里?PS
Sipner
像脊柱还是像纺纱机一样纺纱?;)另外,为什么要为手动变速器使用占位符?为什么不使用手动变速器作为默认值,或者使用禁用的选项,如--选择变速器类型--
?这意味着该字段仅保留为空。我的验证代码在服务器端实现。但是,它不会转到服务器。我看到信息“请填写此字段”。其他浏览器允许字段到服务器。Firefox没有。在Firefox中,右键单击表示未填写的表单字段元素,然后按Q
键“快速检查”。这通常发生在该元素上有required=“true”
(或required=“required”
)属性/值时。如果没有在元素(ev
在开发者检查器工具(Q
)中的元素右侧)或父元素表单
上查找事件侦听器。另外,您似乎没有发布相关元素的代码。祝你好运