我有一个基本的注册表单:检查密码的onsubmit
<form action="adduser" method="post" onsubmit='passwordCheck()'>
Email Address: <input type="email" name="email" required autocomplete="on" placeholder="[email protected]"/><br/>
Username: <input type="text" name="username" maxlength=25 required placeholder="JoyfulSophia"/><br/>
Password: <input type="password" name="password" id='password' onkeydown='checkPassword()' maxlength=30 required placeholder="**********" />
Password (Again): <input type='password' id='pass_repeat'/>
<br/>
<br/>
<input type="submit" value="Send" /> <input type="reset">
</form>
所以表单提交时,它调用passwordCheck(),测试其对容易被猜到的密码,而不是重复相同的密码等,这使该错误(如果有的话)在<p>
(未示出)中。 checkPassword()的作品和错误显示正确,但表格仍然提交,而我读过的JS文档说,如果onsubmit返回false,表单不应该提交。
为什么在checkPassword()返回false时提交表单?而且,密码输入中的每个按键都不会调用checkPassword()。