Reputation: 37
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>
Upvotes: 0
Views: 53
Reputation: 12356
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
The only issue is that getElementById was not correctly written. It is case sensitive.
Upvotes: 0
Reputation: 38121
It's just a typo - the first two lines of verify()
have document.getElementbyId
instead of document.getElementById
(capital B).
Upvotes: 3