I tried the following code for digits-only validation for a contact number validation in Mvc web app.
[RegularExpression(@"/(^(d{10})?)$/", ErrorMessage = "Please enter proper contact details.")]
[Required]
[Display(Name = "Contact No")]
public string ContactNo { get; set; }
But the validation expression is not working.
For the contact number I want to only accept digits. It can be either a 10 digit mobile number or a land-line number.
See Question&Answers more detail:os