Probably very silly issue but looking for help on this .
I am adding MVC Fluent validation rules to model property but for some reason one of the validation rule is failing. Added a regular expression to allow english and spanish characters and no numeric or special characters allowed except - and '. For some reason when user enters more than one valid character as input the error is still displayed.
Error is still displayed when User Input is aA
I am using this RegE @"^[a-zA-Z-']$") to allow users to english and spanish characters and no numeric or special characters allowed except - and '.
Any help is appreciated.
RuleFor(x => x.FirstName)
.NotEmpty().WithLocalizedMessage(ResourceAreas.Messages.Message_PersonalDetails_1001_firstname)
.Length(1,
20).WithLocalizedMessage(ResourceAreas.Messages.Message_Onboarding_100006_maxlength)
.Matches(@"^[a-zA-Z-']$").WithLocalizedMessage(ResourceAreas.Messages.Message_Onboarding_PersonalDetails_100007_validname);
Updating the RegE worked - Thankyou all
@"^[a-zA-Z-']*$";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With