我完全糊涂了......我发誓这昨天有效......我今天早上醒来,我的所有表格都停止在我的项目中工作.
I'm completely confused ... I'd swear this was working yesterday ... I woke up this morning and all my forms stopped to work in my project.
所有表单都有一个onsubmit"到一个返回 false 的函数,因为它是一个 ajax 调用,所以表单永远不会被发送.
All the forms have a "onsubmit" to a function that returns false since it's an ajax call, so the form is never sent.
经过大量测试,我将问题简化为这段代码:
After a lot of tests, I simplified the question to this piece of code:
<html> <head> <script type="text/javascript"> function sub() { alert ("MIC!"); return false; } </script> </head> <body> <form method = "post" id = "form1" onsubmit = "return sub()"> input: <input type="text" name="input1" > <a href="#" onClick="document.getElementById('form1').submit();">button</a> </form> </body> </html>我发誓这很完美,但今天也不行:D
I would swear that this works perfectly, but today is nor working :D
为什么我按下按钮会发送表单?
Why if I press the button the form is sent ?
我知道这是一个新手问题,但我被卡住了
I know it's a total newbie question, but I'm stuck
谢谢!
推荐答案如果您以编程方式调用 submit(),浏览器不调用表单上的 onSubmit 事件.
Browsers do not call the onSubmit event on the form if you call submit() programmatically.
更多推荐
onSubmit 返回 false 不起作用
发布评论