表单的输入类型=“提交”似乎没有触发onsubmit处理程序 [英] Form's input type="submit" does not seem to trigger the onsubmit handler

查看:218
本文介绍了表单的输入类型=“提交”似乎没有触发onsubmit处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过onsubmit来触发一个javascript函数来验证我的表单。



我知道函数本身的作用,因为我可以在脚本标记之后立即调用它表单的标记和我收到我的console.log消息和它创建的错误消息出现在窗体上。



PHP验证本身有效,但我只能通过放置在div上的javascript .submit 实际提交表单。很明显,因为这绕过了任何客户端验证,所以我不能这样离开它,因此我用<$ c $替换了 div id =submit c> input type =submit。



我一直在寻找其他例子,包括过去编码过的表单我知道工作,看起来完全没有答案。这可能非常容易,出于某种原因,我不能也不能在过去6个小时内看到它。 o_O



以下是我的表单标记:

 <表单名称=emailusid =emailusaction =<?php echo $ _SERVER ['PHP_SELF'];?> method =postonsubmit =return validateForm();> 
< a href =mailto:example@email.com>
< h3>< i class =icon-envelope-alt icon-large>< / i>向我们发送电子邮件< span> ;: example@email.com< / span>< H3>
< / a>

< div class =half>
< fieldset class =name>
< label for =cf_name>< h4>名称< / span> *< / span>< / h4>< / label>
< input type =textname =cf_nameclass =textualformfieldalt =Jane Doepattern =^ [a-zA-Z'\\s] + $>
< / fieldset>
< fieldset class =emailaddress>
< label for =cf_email>< h4>电子邮件< span> *< / span>< / h4>< / label>
< input type =textname =cf_emailclass =textualformfieldalt =janedoe@email.compattern ={long string of regex}>
< / fieldset>
< fieldset class =phonenumber>
< label for =cf_phonenumber>< h4>手机< / h4>< / label>
< input type =telname =cf_phonenumberclass =textualformfieldalt =555-555-5555>
< / fieldset>
< fieldset class =eventdate>
< label for =cf_eventdate>< h4> Event Date< / h4>< / label>
< input type =textname =cf_eventdateclass =textualformfieldalt =2012年5月25日>
< / fieldset>
< fieldset class =location>
< label for =cf_location>< h4>位置< / h4>< / label>
< input type =textname =cf_locationclass =textualformfieldalt =The Church>
< / fieldset>
< / div>

< div class =half>