jquery判断两次密码不一致

jquery检测输入密码两次不一样提示

输入密码: <input type="password" name="password1" />

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;

}

}