2016-08-04 183 views
-2

在更改密碼時,應該有1.當前密碼2.新密碼和3.確認單個用戶的密碼。 我需要一個代碼來驗證當前密碼與新密碼。 如果當前密碼和新密碼是相同的,應該拋出的錯誤「密碼已經存在,請選擇其他」MVC驗證更改密碼。當前密碼與新密碼

回答

0

的功能例如可以是這樣的:

void validatePassword(string currentpw, string newpw) 
{ 
    if (newpw == currentpw) 
     throw new Exception("Password already exist please 
choose another"); 
} 

現在,這是非常斷章取義