为什么我无法手动提交此表单? [英] Why can't I manually submit this form?
本文介绍了为什么我无法手动提交此表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< form method =postid =weber-formclass = af-form-wrapperaction =http://www.aweber.com/scripts/addlead.pl>
< input class =textInputawebtype =textname =emailid =emailsize =20value ='Enter Email'onfocus =if(this.value =='Enter电子邮件'){this.value ='';}onblur =if(this.value ==''){this.value ='Enter Email';}/>
< input id =submitname =submitclass =submitawebertype =submitvalue =Submit/>
< / form>
< script>
$(function(){
$('#submit')。click(function(e){
e.preventDefault();
//做点什么...
$('#weber-form')。submit();
});
}
< / script>
解决方案
对于以下脚本来说,提交按钮必须 NOT 具有名称
或 id
< input class =submitawebertype = submitvalue =Submit/>
演示: http://jsfiddle.net/MYht8/
//我们绑定到表单而不是表单按钮
//使用.on()(jQ1.7 +)
$('#weber-form')。on('submit',function(e){
// prev表单提交
e.preventDefault();
//做的东西
//使用本地提交,所以我们不会触发
//这个处理程序再次
this.submit();
});
});
I'm trying to get something done before my form submits. The following code runs through without errors, but my form never gets submitted. I can't tell what's wrong..
<form method="post" id="weber-form" class="af-form-wrapper" action="http://www.aweber.com/scripts/addlead.pl">
<input class="textInputaweb" type="text" name="email" id="email" size="20" value='Enter Email' onfocus=" if (this.value == 'Enter Email' ) { this.value = ''; }" onblur="if (this.value == '') { this.value='Enter Email';} " />
<input id="submit" name="submit" class="submitaweber" type="submit" value="Submit" />
</form>
<script>
$(function() {
$('#submit').click(function (e) {
e.preventDefault();
// Do something...
$('#weber-form').submit();
});
}
</script>
解决方案
for the following script to work, the submit button must NOT have a name
or id
with the value "submit". a button like this will work:
<input class="submitaweber" type="submit" value="Submit" />
Demo: http://jsfiddle.net/MYht8/
$(function() {
//we bind to the form instead of the form button
//using .on() (jQ1.7+)
$('#weber-form').on('submit', function(e) {
//prevent form submission
e.preventDefault();
//do stuff
//use the native submit so we wont trigger
//this handler again
this.submit();
});
});
这篇关于为什么我无法手动提交此表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文