Here are some of my code for the Semester example field in ASP.NET MVC:
[Display(Name = "Semester:"), Required(ErrorMessage = "Please fill in the Semester of the Issue"), StringLength(25)]
This will specifically cause an error message if the field is empty.
You can also add regular expressions if you want. i.e:
[RegularExpression(@"^http(s?)\:\/\/[0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*(:(0-9)*)*(\/?)([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$", ErrorMessage = "Link format is wrong")]
This code will verify that the URL is in the appropriate format.
This should be very close to what you are looking for, although if it is not, I will be happy to delete my answer.
source share