jquery检测输入密码两次不一样提示
输入密码: <input type="password" name="password1" id="password1"/>
确认密码: <input type="password" name="password2" id="password2" οnkeyup="validate()"/> <span id="tishi"></span> <input type="submit" value="注册" id="submit"/>
js部分
function validate() {
var password1 = document.getElementById("password1").value; var password2 = document.getElementById("password2").value; if(password1 == password2) { document.getElementById("tishi").innerHTML="<font color='green'>两次密码相同</font>"; document.getElementById("submit").disabled = false; } else { document.getElementById("tishi").innerHTML="<font color='red'>两次密码不相同</font>"; document.getElementById("submit").disabled = true; } }