表单不是在chrome上提交,而是在firefox中提交
Form not submiting on chrome but in firefox submitting
我有一个提交按钮,如下:
保存,继续
And My function in js是:
function checkCreditDebit(buttonValues) {
//Some validation here
//Disable Button if once clicked to prevent twice form submission
document.getElementById('saveandcontinue').disabled = 'disabled';
document.getElementById('onlysave').disabled = 'disabled';
}
但是当我在firefox中提交表单时,它禁用了"保存&按钮,然后提交表单。但在chrome浏览器中,它禁用按钮,但不提交表单。这有什么问题,请告诉我。
而不是仅仅禁用你的提交按钮(表单也可以提交,如果你在文本框上按enter键),附加一个处理程序到你的表单,将留下一个'类名'给你的表单作为一个标记,表单已经提交,如果用户再次提交表单,处理程序应该检查表单是否已经有类名,然后通过event.preventDefault()防止重复提交。
试试这个:
<form onsubmit="prevent_duplicate(event,this);" action="">
<input type="text" />
<input type="submit" />
</form>
<script>
function prevent_duplicate(event,form)
{
if((" "+form.className+" ").indexOf(" submitted ") > -1)
{
alert("can't submit more than once!!!");
event.preventDefault();
}
else
{
form.classList.add("submitted");
}
}
</script>
Demo instead of disabling pervent multiple submit by setting a javascript flag example :
<form method="post" id="ecomFormBean" name="ecomFormBean" onsubmit="return checkSubmit(this);" >
<input type="text" />
<input type="submit" />
</form>
<script>
var formSubmitted = false;
function checkSubmit(f){
if (formSubmitted) {
alert('Please be patient. Your order may take 10 - 15 seconds to process. Thank you!');
return false;
}
else return formSubmitted = true;
}
</script>
Chrome运行javascript非常快。所以它可能是你的checkCreditDebit(buttonValues)函数,这是禁用提交按钮执行之前,你的php脚本提交表单。
我建议你在调用javascript函数之前调用setTimeOut函数,以便表单可以被提交。
试试吧
相关文章:
- Firefox,如何提交表单触发文件下载,但停留在网页上
- jquery表单提交无法使用多个输入(IE和Firefox)
- writeln img src将数据提交到外部系统-Firefox和IE挂起
- 提交输入不'不要在IE和Firefox中发布
- 在firefox中,在向表单添加onsubmit属性后,不会提交表单
- 提交按钮不会;不适用于Chrome或Firefox,但适用于Internet Explorer
- Firefox插件-在提交之前捕获post变量[no-enctype]
- Firefox 和 Jquery/Javascript 表单提交
- 此代码阻止我的表单提交(仅在 chrome 中,适用于 IE 和 Firefox)
- 点击提交按钮使用javascript和Firefox
- TinyMCE - 在 Firefox 中,值不会提交
- javascript 生成的提交按钮在 Firefox 中未发布
- 提交按钮不会出现在Firefox中,而是出现在Chrome和Internet Explorer上
- Firefox “加载”轮在 iFrame 提交后继续旋转
- Ajax在Chrome / Safari中提交作品,但不能在Firefox / IE中提交作品
- 另一种方法是让chrome、IE 8和firefox提交相同的表单
- <按钮>在firefox上提交,防止默认
- 点击提交按钮禁用然后表单提交在firefox上工作,但不在chrome&狩猎
- FireFox不要'T取消表单提交从jQuery脚本
- Firefox 31的javascript提交不工作