Data Annotation to validate confirm password

前端 未结 3 1390
醉梦人生
醉梦人生 2021-02-01 12:37

My User model has these data annotations to validate input fields:

[Required(ErrorMessage = \"Username is required\")]
[StringLength(16, ErrorMessage = \"Must be         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 13:16

    Other data annotations are optional you can add those according to your requirement but you need to do this to implement password comparison operation

    [Required]
    [DataType(DataType.Password)]
    public string Password { get; set; }
    
    [Required]
    [DataType(DataType.Password)]`enter code here`
    [Compare("Password")]
    public string ConfirmPassword { get; set; }
    

提交回复
热议问题