I'm struggling with a password comparison issue in JavaScript. It was working fine on my previous project, but for some reason it's not working now. Here is the HTML code:
<form>
<label>
<strong>Username</strong>
<input type="text" name="">
</label>
<label>
<strong>Password</strong>
<input type="password" name="" id="password">
</label>
<label>
<strong>Confirm Password</strong>
<input type="password" name="" id="confirmpassword">
</label>
<button class="button" type="submit" id="button" onclick="click();">Submit</button>
</form>
And here is the corresponding JavaScript code:
function click (){
var password = document.getElementID('password').value,
confirmpassword = document.getElementID('confirmpassword').value
if (password == ""){
alert("Field cannot be empty.");
}
else if (password != confirmpassword){
alert("Passwords don't match. Please try again.");
return false
}
else if(password == confirmpassword){
alert("Password Match")
}
return false
}