简体   繁体   English

检查密码是否匹配不起作用

[英]Check if passwords match not working

Well I'm trying to work on how to verify the passwords if they match, I tested it multiple times and tried to change bits of it but it still won't say Verified or Not Verified... I'm sorry if I failed to see something obvious and I also tried searching the web a bit, but I really need to get this done. 好吧,我正尝试研究如何验证密码是否匹配,我对其进行了多次测试并尝试更改它的位,但仍然不会说“已验证”或“未验证” ...对不起,我很抱歉为了看到明显的东西,我也尝试了一下网络搜索,但是我确实需要完成这项工作。 Help is much appreciated. 非常感谢您的帮助。

<html>
<head>
<title>FA3</title>
</head>
<body>
<style type="text/css">
.font
{
font-family:Helvetica Neue;
text-align:center
}
</style>
<div class="font">
<h2>Verify Password</h2>
Type Password : <input type="text" id="first">
<br>
Retype Password : <input type="text" id="second">
<hr>
<button onclick="verify()">Submit</button>
<br>
<p id="result">Your Password is</p>
</div>
<script>
function verify(){
   var t = document.getElementbyId("first").value;
   var r = document.getElementbyId("second").value;
if (t==r){
document.getElementById("result").innerHTML ="Verified"
}
else{
document.getElementById("result").innerHTML ="Not Verified"
}}
</script>
</body>
</html>

这只是一个错字-verify verify()的前两行包含document.getElementbyId而不是document.getElementById (大写B)。

Here is the working code: 这是工作代码:

<html>
<head>
<title>FA3</title>
</head>
<body>
<style type="text/css">
.font
{
font-family:Helvetica Neue;
text-align:center
}
</style>
<div class="font">
<h2>Verify Password</h2>
Type Password : <input name="first" type="text" id="first">
<br>
Retype Password : <input name="second" type="text" id="second">
<hr>
<button onclick="verify()">Submit</button>
<br>
<p id="result">Your Password is</p>
</div>
<script>
function verify(){
   var t = document.getElementById("first").value;
  var r = document.getElementById("second").value;
if (t==r){
document.getElementById("result").innerHTML ="Verified"
}
else{
document.getElementById("result").innerHTML ="Not Verified"
}}
</script>
</body>
</html>

https://jsbin.com/cataweboda/edit?html,output https://jsbin.com/cataweboda/edit?html,输出

The only issue is that getElementById was not correctly written. 唯一的问题是getElementById编写不正确。 It is case sensitive. 区分大小写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM