当前位置:Gxlcms > JavaScript > Jquery submit()无法提交问题

Jquery submit()无法提交问题

时间:2021-07-01 10:21:17 帮助过:19人阅读

代码如下:

<form action="register.php" method="post">
<div class="loginform_row">
<label>用户名:</label>
<input type="text" class="loginform_input" id="name" name="name" /><div id="nameerror"></div>
</div>
<div class="loginform_row">
<label>密码:</label>
<input type="text" class="loginform_input" id="pass" name="pass" /><div id="passerror"></div>
</div>
<div class="loginform_row">
<label>邮箱:</label>
<input type="text" class="loginform_input" id="email" name="email" /><div id="emailerror"></div>
</div>
<div class="loginform_row">
<input type="button" class="loginform_submit" id="submit" value="注册" />改为<input type="button" class="loginform_submit" id="register" value="注册" />
</div>
<div class="clear"></div>
</form>
$("#submit").click(function() {
$("form").submit();
});

上述代码点击注册按钮时无法提交表单

原因
Additional Notes:
Forms and their child elements should not use input names or ids that conflict with properties of a form, such as submit, length, or method. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.

其他注意事项
表单和其子元素不宜用一个表单的属性的属性作为name或id的名称,如submit, length, or method,是、会产生冲突。名称冲突可能会导致混乱的失败。对于一个完整的规则列表,并检查这些问题标记,看DOMLint。
所以将注册按钮的id改为“register”就OK了

人气教程排行