开发者

Form validation fails but submits page

开发者 https://www.devze.com 2023-02-22 22:53 出处:网络
I have a form which uses GET as the method. I want to do some js validation on the form. I bind the event using

I have a form which uses GET as the method. I want to do some js validation on the form. 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 开发者_Python百科and data.

Any ideas?


Simply adding an event handler doesn't stop it from submitting.

You need to add in preventDefault();

(Documentation)

0

精彩评论

暂无评论...
验证码 换一张
取 消