我想弄清楚如何驗證用戶在註冊時輸入了匹配的密碼。是否有內置於MVC 4數據註釋的內容,我可以使用它或者是創建自定義驗證屬性的唯一途徑?ASP.NET MVC 4交叉字段或屬性驗證
如果我必須創建一個自定義驗證屬性,我該如何訪問密碼屬性(假設我將註釋放在confirm密碼屬性上)?另外,這種類型的驗證是否有任何常用的庫?
這是我有一個自定義驗證屬性的開始,只是不知道如何訪問密碼屬性:
public class CrossFieldValidationAttribute : ValidationAttribute
{
public override bool IsValid(object value) //how do I get the other value in here?
{
//validation logic here
return base.IsValid(value);
}
}
我明白任何幫助!
在創建登錄帳戶時將密碼與數據庫匹配或匹配密碼? (因此註冊)? – bas 2013-03-17 20:03:06