FireFox提交表格两次 [英] FireFox submitting form twice

查看:86
本文介绍了FireFox提交表格两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两种在FireFox中行为不端的表单,但在IE中工作正常。


当我提交(使用提交按钮)时,javascript函数验证所有字段输入,如果出现错误则停止提交。


示例(显然不是正常工作代码):

[HTML]< html>

< head>

< script type =" text / javascript">

功能提交()

{

//在提交之前做一些事情,比如表格字段验证

返回true;

}否则{

返回false; //什么都不做,不要提交表格

}

}

< / script>

< ; / head>

< body>

< form name =" myForm"行动= QUOT; form.cgi" onSubmit =" return Submit()>

这里的一些表格字段< br />

< input type =" submit"值= [提交" >

< / form>

< / body>

< / html>

[/ HTML]



问题:

在IE中,脚本执行为预计。


在FireFox中(在v2.0.0.3中测试):

*如果表单验证正确,则会提交两次:

*如果表单没有验证那么什么也没发生。


我在这里编码错了吗?为什么FireFox提交表单两次..

I have a couple of forms that are misbehaving in FireFox, but work fine in IE.

when i do submit( with submit button) a javascript function validates all of the fields entered, and stops the submission if there is an error.

Sample (obviously not working code):
[HTML] <html>
<head>
<script type="text/javascript">
function Submit()
{
// do something, like form field validation before submitting
return true;
} else {
return false; // do nothing, do not submit the form
}
}
</script>
</head>
<body>
<form name="myForm" action="form.cgi" onSubmit="return Submit()>
Some form fields here<br/>
<input type="submit" value="Submit" >
</form>
</body>
</html>
[/HTML]



THE PROBLEM:
In IE, the script performs as expected.

In FireFox (tested in v2.0.0.3):
* if the form validates correctly, it gets submitted twice:
* if the form doesn''t validate then nothing happen.

Am I coding something wrong here? Why is FireFox submitting the form two times..

推荐答案


我有几种在FireFox中行为不端的表单,但在IE中工作正常。


当我提交(使用提交按钮)时,javascript函数验证输入的所有字段,并在出现错误时停止提交。 />

样本(显然不是工作代码):

< html>

< head>

< script type =" text / javascript">

函数提交()

{

//做点什么,比如表单字段提交前验证

返回true;

}否则{

返回false; //什么都不做,不要提交表格

}

}

< / script>

< ; / head>

< body>

< form name =" myForm"行动= QUOT; form.cgi" onSubmit =" return Submit()>

这里的一些表格字段< br />

< input type =" submit"值= [提交" >

< / form>

< / body>

< / html>



问题:

在IE中,脚本按预期执行。


在FireFox中(在v2.0.0.3中测试):

*如果表单验证正确,则会提交两次:

*如果表单没有验证然后没有任何事情发生。


我在这里编码错了吗?为什么FireFox提交表格两次..
I have a couple of forms that are misbehaving in FireFox, but work fine in IE.

when i do submit( with submit button) a javascript function validates all of the fields entered, and stops the submission if there is an error.

Sample (obviously not working code):
<html>
<head>
<script type="text/javascript">
function Submit()
{
// do something, like form field validation before submitting
return true;
} else {
return false; // do nothing, do not submit the form
}
}
</script>
</head>
<body>
<form name="myForm" action="form.cgi" onSubmit="return Submit()>
Some form fields here<br/>
<input type="submit" value="Submit" >
</form>
</body>
</html>



THE PROBLEM:
In IE, the script performs as expected.

In FireFox (tested in v2.0.0.3):
* if the form validates correctly, it gets submitted twice:
* if the form doesn''t validate then nothing happen.

Am I coding something wrong here? Why is FireFox submitting the form two times..



我不是FireFox的大师,我只是在这里试试运气,

如果你调用onClick函数onClick而不是onSubmit形式会发生什么?

I''m not a FireFox guru and am just trying my luck here,
What happens if you call the function onClick of the submit button rather than onSubmit of the form?


尝试更改函数名称



尝试更改函数名称
try to change the function name



当然。应该是它。

Of course. That should be it.


这篇关于FireFox提交表格两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆