密码验证
function validate() {
var pwd1 = document.getElementById("password").value;
var pwd2 = document.getElementById("absPassword").value;
if (pwd1 == pwd2 && pwd1!='' && pwd2!='') {
document.getElementById("passError").innerHTML = "<font color='green'>两次密码相同</font>";
}
else {
document.getElementById("passError").innerHTML = "<font color='red'>两次密码不相同</font>";
}
}
function password() {
var a = document.getElementById("btn").title;
if (a=='s') {
document.getElementById("password").type = "text";
document.getElementById("btn").title = "h";
} else if (a == 'h') {
document.getElementById("password").type = "password";
document.getElementById("btn").title = "s";
}
}
function password1() {
var a = document.getElementById("btn1").title;
if (a == 's') {
document.getElementById("absPassword").type = "text";
document.getElementById("btn1").title = "h";
} else if (a == 'h') {
document.getElementById("absPassword").type = "password";
document.getElementById("btn1").title = "s";
}
}
<li class="form-group">
<label for="exampleInputPassword1"><span class="error"></span><span id="leftText">*密码:</span></label>
<button id="btn" onclick="password()" title="s">s</button><input type="password" class="form-control" ng-model="form.password" id="password" placeholder="至少三位数字">
</li>
<li class="form-group">
<label for="exampleInputFile"><span class="error"></span><span id="leftText">*确认密码:</span></label>
<button id="btn1" onclick="password1()" title="s">s</button><input type="password" class="form-control" id="absPassword" ng-model="form.passwordCha" placeholder="Password" onkeyup=" validate()">
<p id="passError"></p>
</li>