Gcobani Mkontwana

Gcobani Mkontwana

  • 568
  • 1.9k
  • 406.7k

How to bind form fields using data-annotation?

Jun 16 2020 9:06 AM
Hi Team
 
I have this model and want to bind form field using data-annotation. My problem i cant seem to bind them as once, using one error. Anyone who can help me on this please? Example is on my screenshot view of the form. 
  1. [Required]  
  2. public string StreetAddress { getset; }  
  3.   
  4. [Required]  
  5. public string StreetAddressLine { getset; }  
  6.   
  7. [Required]  
  8. public string City { getset; }  
  9.   
  10. [Required]  
  11. public string StateProvince { getset; }  
  12.   
  13. [Required(ErrorMessage = "This field is required")]  
  14. public int ZipCode { getset; }  

Answers (1)