除非您有充分的理由使用仅 javascript 提交,否则为什么在出现 javascript 错误时将表单设置为不可用?
使用 submit 类型的标准表单输入,给它一个 id,根据需要通过 javascript 更改提交的外观或文本,并在该功能之上创建 onclick 和 onsubmit 事件并让它们返回 false。更好的后备方案。
我不确定你为什么要尝试一次提交两个表单,但是这个替代方案怎么样(请注意,我没有测试过这段代码,但它应该传达这个想法):
<script type='text/javascript'>
$('#fallback-register-submit').hide(); // Hide the submit button.
$('#registration-link').show().click(function (){ // Show the link and attach the action.
$('#registerForm').submit();
return false; // Don't bother following the link anchor.
});
</script>
<form name="registerForm" id="registerForm" target="_blank" action="paypal_url" method="post""><!-- Single form that does all of the submitting. -->
...
...
<input type='submit' id='fallback-register-submit'>Register</input><!-- In the event of a javascript error for their browser, they can still buy your stuff! -->
<a id='registration-submit' style='display:none'>Go to paypal and send confirmation mail</a>
</form>