Directly upload the code:
<div id="register"><h4>Member Registration</h4><div><form method="post" action="register.php?action=register" name="register" id="registerForm"><dl><dt>Please fill in the following carefully</dt><dd>Username: <input type="text" name="username"></dd><dd>Password: <input type="password" name="pwd"></dd><dd>Confirm password: <input type="password" name="pwdagain"></dd><dd id="tximg"><img src="img/face/m01.gif" id="faceimg"><input type="hidden" name="touxiang" value=""><label id="imgsrclabel">m01.gif</label></dd><dd style="margin-right:120px;">Verification code: <input type="text" name="code"><span><img src="code.php" id="code" name="code"><a href="#code" id="change">change"</a></span></dd><dd><input type="button" name="submit" id="submit" value="register"><input type="button" name="quit" id="quit" value="exit"></dd></dl></form></div></div>Form data is submitted to this page. The following is js processing/*Register form submission*/function formDeal(){var btnSubmit = document.getElementById('submit');var formId = document.getElementById('registerForm');btnSubmit.onclick = function(){//The submit() method of the form cannot submit the form formId.submit();}}If the form is submitted, there is a prompt message on this page if(!empty($_GET['action']) && $_GET['action'] == 'register'){echo 'You submitted the data';exit();}As a result, I didn't see the prompt message after testing for a long time. I thought the code was wrong or the method was written incorrectly. I checked it carefully and confirmed that there was no error in the official results document.
formId.submit() cannot be submitted, so I have to change the type of btnSubmit to submit for the time being
this.type="submit"
I checked the information online, and the reasons are reduced to two points:
1. There cannot be a label with name=”submit” in the form
2. "enctype="multipart/form-data"" cannot be missing in the form
After testing, these two points are absurd and did not solve my problem (maybe my problem environment is different)
Later, I thought that the forum friends suggested that I change the ID of the registration button to name it without submitting it. After correction, the form is submitted normally and the prompt message appears.
Finally, the button's id should not be set to submit, otherwise it may cause confusion, resulting in the form's submit() method cannot submit the form. When naming IDs, it is best not to repeat the name with the existing API to avoid unnecessary trouble.