Javascript 重新键入密码验证
请给我一些JavasSript代码,以便我可以在更改密码时执行重新键入密码验证。非常简单,但以下代码可以放在表单的提交事件上,以便在用户尝试保存时检查两个输入Javascript 重新键入密码验证,javascript,Javascript,请给我一些JavasSript代码,以便我可以在更改密码时执行重新键入密码验证。非常简单,但以下代码可以放在表单的提交事件上,以便在用户尝试保存时检查两个输入 var password1 = document.getElementById("password1input"); // get a reference to the first input var password2 = document.getElementById("password2input"); // get a refer
var password1 = document.getElementById("password1input"); // get a reference to the first input
var password2 = document.getElementById("password2input"); // get a reference to the second input
if (password1.value != password2.value) { // compare the values
alert("They don't match!"); // alert the user
return false; // prevent the form from submitting
}
您还需要扩展“重新键入密码验证”的定义