Home > Article > Web Front-end > Problems caused by naming form items as submit and reset_Form special effects
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!