Compare password and confirm password in ASP.Net MVC

后端 未结 6 1046
遥遥无期
遥遥无期 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:42

    Using Compare DataAnnotation it will be easy to compare password but if model genrate from database use NotMapped, NotMapped Properties In An Entity Framework Using A Code-First Strategy

    [Required]
    public string Password { get; set; }
    
    [NotMapped] // Does not effect with your database
    [Compare("Password")]
    public string ConfirmPassword { get; set; }
    

提交回复
热议问题