Reputation: 81
I am doing UserId validation. I have added regex validation to allow numbers and characters in user id.
[RegularExpression(@"^[A-Za-z0-9]*$", ErrorMessage = "Only characters and digits are allowed")]
How can I allow the "@" symbol in Userid but not as the first character?
Upvotes: 1
Views: 1026
Reputation: 25221
The following regex should see you through:
@"^[A-Za-z0-9]+[A-Za-z0-9@]*$"
Upvotes: 1