Compare password and confirm password in ASP.Net MVC

后端 未结 6 1173
遥遥无期
遥遥无期 2021-02-07 06:32

Is it possible to compare confirm password textbox\'s text with @Html.PasswordFor(model=>model.Password)?

@using (Html.BeginForm())
{
    

        
6条回答
  •  没有蜡笔的小新
    2021-02-07 06:52

    Just add [NotMapped] to above of your Confirm password Property in Data Model

    [NotMapped]
    [Required(ErrorMessage = "Confirm Password required")]
    [CompareAttribute("NewPassword", ErrorMessage = "Password doesn't match.")]        
    public string ConfirmPassowrd { get; set; }
    

    By this way, it will not check ConfirmPassword property in your DB table

提交回复
热议问题