user3824109
user3824109

Reputation: 81

Allow @ special character but not as first character

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

Answers (1)

Ant P
Ant P

Reputation: 25221

The following regex should see you through:

@"^[A-Za-z0-9]+[A-Za-z0-9@]*$"

Upvotes: 1

Related Questions