While doing validation you need to put validation apart from that you need to provide the regular expression
in cases where only specific values are allowed to enter otherwise user cannot enter it
Regular expressions are series of combinations of letters and symbols that will provide this work for us
public class Details
{
[Required]
[Display(Name = "Name")]
[RegularExpression(@"^[a-zA-Z]+$", ErrorMessage = "Use letters only please")]
public string Name;
[Required]
[Display(Name = "DOB")]
public string dob;
[Required]
[Display(Name = "Hobbies")]
public IEnumerable<SelectListItem> Hobbies;
[Required]
[Display(Name = "Country")]
public IEnumerable<SelectListItem> Country;
[Required]
[Display(Name = "Category")]
public IEnumerable<SelectListItem> Category;
public string getcategory;
public string getcountry;
public string gethobbies;
public string value;
}
In this model class i have done validation to enter only characters while providing name of the user in the registeration process
0 Comment(s)