Guest User

Guest User

  • Tech Writer
  • 41
  • 16.5k

Unique field validator using MVC 5 C#

Jun 16 2015 6:34 AM

I am currently building a system for my University project and doing validation for an individuals ID number. I am having difficulty finding validation to make the ID number unique so that it may not be duplicated and each user in the system has a unique ID number, I edited the validation for it to be 13 digits from my phone number validation.... this is my code:

 


 [Required(ErrorMessage = "The ID number field must be completed")]


        [RegularExpression(@"^\(?([0-9]{6})\)?[-. ]?([0-9]{4})[-. ]?([0-9]{3})$", ErrorMessage = "Not a valid 13 digit ID number")]


        public string id_no { get; set; }





 

Answers (2)