简体   繁体   English

表单验证失败但提交页面

[英]Form validation fails but submits page

I have a form which uses GET as the method.我有一个使用 GET 作为方法的表单。 I want to do some js validation on the form.我想对表单进行一些 js 验证。 I bind the event using我使用绑定事件

document.forms[0].onsubmit = function(){return myObj.myFrm.isFormValid();}. 

In Firefox it works the first time I click on submit but after a while if I click it again the form submits even though I've not changed and data.在 Firefox 中,它在我第一次单击提交时起作用,但过了一会儿,如果我再次单击它,即使我没有更改和数据,表单也会提交。

Any ideas?有任何想法吗?

Simply adding an event handler doesn't stop it from submitting.简单地添加一个事件处理程序并不能阻止它提交。

You need to add in preventDefault();您需要添加preventDefault();

( Documentation ) 文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM