这是我的代码:
<form name='frm' id='frm' action='load.asp' method='post' onSubmit='return OnSubmit(this)' style='margin-top:15px'>
<input type='submit' name='send' id='send' onclick="this.disabled=true;return true;" value='Send' title='test'>
</form>
我希望执行 onsubmit 函数并提交页面。
在我的网站中,没有提交也没有功能
我试图在这里复制它,但表单似乎已发布,而我的函数从未被执行......http://jsfiddle.net/V7B3T/1/ http://jsfiddle.net/V7B3T/1/
我不知道什么时候应该重新激活按钮。
我应该在 document.ready 中还是在 onSubmit 函数中执行此操作?
因此,如果有人可以修复小提琴:),之后我会将其与我的代码进行比较。
我想:S我迷路了
谢谢大家
如果您想在提交之前验证表单或进行任何更改,并且仅在表单有效时才提交,您可以执行以下操作:
<form id="frm" action="load.asp" method="post" enctype="multipart/form-data">
<input type="submit" name="send" id="send" value="Send" title="test">
</form>
和 JavaScript 代码:
$('#frm').bind('submit', function (e) {
var button = $('#send');
// Disable the submit button while evaluating if the form should be submitted
button.prop('disabled', true);
var valid = true;
// Do stuff (validations, etc) here and set
// "valid" to false if the validation fails
if (!valid) {
// Prevent form from submitting if validation failed
e.preventDefault();
// Reactivate the button if the form was not submitted
button.prop('disabled', false);
}
});
这是一个工作fiddle http://jsfiddle.net/V7B3T/631/.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)