我在这里有一些html代码。
<tr>
<td align="right" for="psw">Password</td>
<td>
<input style="width: 100%"
type="password"
id="password"
name="password"
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}"
title="Must contain at least one number and one uppercase and lowercase letter, and at least 6 or more characters"
onchange="check_pass()"
required/>
</td>
</tr>
<tr>
<td align="right" for="confirm_password">Confirm password</td>
<td>
<input style="width: 100%"
type="password"
id="confirm_password"
name="confirm_password"
onchange="check_pass()"
required/>
</td>
</tr>
我在confir_password上遇到问题
这是我的js代码:
var myInput = document.getElementById("password");
myInput.onfocus = function() {
document.getElementById("message").style.display = "block";
}
myInput.onblur = function() {
document.getElementById("message").style.display = "none";
}
这个是用于confirm_password的。
var myInput = document.getElementById("password")
, confirm_password = document.getElementById("confirm_password");
function validatePassword(){
if(myInput.value != confirm_password.value) {
confirm_password.setCustomValidity("Passwords Don't Match");
} else {
confirm_password.setCustomValidity('');
}
}
myInput.onchange = validatePassword;
confirm_password.onkeyup = validatePassword;
我不知道要解决此问题。对于Confirm_Password似乎根本不起作用。 希望有人可以帮助我。