Home > Web Front-end > JS Tutorial > Problems caused by naming form items as submit and reset_Form special effects

Problems caused by naming form items as submit and reset_Form special effects

WBOY
Release: 2016-05-16 19:07:17
Original
1399 people have browsed it

Recently, a friend used a form named form as a keyword, which caused the inability to reset and submit. It turned out to be this question: "Is there an error when calling document.forms[0].reset()?", so I immediately asked him: "Does the page have a form?" , answer: "Yes". "Alert document.forms[0]" and "pop up object". That's strange. When did form not have a reset method?
I took a look and found that alert(document.forms[0].reset) pops up object, which is wrong. It should pop up the reset local method. After searching for reset, I found that the original reset button name was reset. No wonder something went wrong. document.forms[0].reset points to the reset button, not the reset interface of the form.

Remove name="reset" and everything is OK!

In fact, I also found that the name of its submit button was submit. I guess there will be an error in adjusting the submit method!
Excuse me: I don’t know if it was generated by software or written by him. Anyway, be careful not to use these keywords in naming, as it is easy for unexpected errors to occur!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template