gpt4 book ai didi

javascript - 确认密码验证

转载 作者:行者123 更新时间:2023-11-28 19:36:19 24 4
gpt4 key购买 nike

我有一个 html 文件,我正在尝试检查两个密码字段(密码和一致密码),我必须使用这个特定的表单,我不能使用任何示例,我在这里查看了示例,但我遇到了一个交叉一个工作示例,我尝试让它工作,但到目前为止还没有工作,我对此很陌生,所以请对此保持耐心

<div id="register" class="animate form">
<form action="mysuperscript.php" autocomplete="on">
<h1> Sign up </h1>
<p>
<label for="usernamesignup" class="uname" data-icon="u">Your username</label>
<input id="usernamesignup" class="username" name="usernamesignup" required="required" type="text" placeholder="mysuperusername690">
<span class="check" ></span>
</p>
<p>
<label for="emailsignup" class="youmail" data-icon="e"> Your email</label>
<input id="emailsignup" name="emailsignup" required="required" type="email" placeholder="mysupermail@mail.com">
</p>
<p>
<label for="passwordsignup" class="youpasswd" data-icon="p">Your password </label>
<input id="passwordsignup" name="passwordsignup" required="required" type="password" placeholder="eg. X8df!90EO">
</p>
<p>
<label for="passwordsignup_confirm" class="youpasswd" data-icon="p">Please confirm your password </label>
<input id="passwordsignup_confirm" name="passwordsignup_confirm" required="required" type="password" onkeyup="checkPasswordMatch(); placeholder="eg. X8df!90EO">
</p>
<p class="signin button">
<input type="submit" value="Sign up">
</p>
<p class="change_link">
Already a member ?
<a href="#tologin" class="to_register"> Go and log in </a>
</p>
</form>

我已将此功能添加到代码中

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
function checkPasswordMatch() {
var password = $("#passwordsignup").val();
var confirmPassword = $("#passwordsignup_confirm").val();

if (password != confirmPassword)
$("#register").html("Passwords do not match!");
else
$("#register").html("Passwords match.");
}
</script>

根据示例,它应该可以工作,但显然我在这里做错了什么,感谢您的帮助。

最佳答案

在您发布的代码中,onkeyup="checkPasswordMatch(); 之后缺少一个 "

关于javascript - 确认密码验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25811995/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com