2010-01-03 93 views
-3

請給我一些JavasSript代碼,以便我可以在更改密碼的同時實施重新輸入密碼驗證。重新輸入密碼驗證

+0

您還需要擴展「重新鍵入密碼驗證」的定義, – Rob 2010-01-03 19:39:37

回答

3

非常簡化,但下面的代碼可以放在窗體的提交事件上,以在用戶嘗試保存時檢查兩個輸入。

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 
}