0

Can any body tell me how to check the Emppty string using Regularexpression

[RegularExpression(@"\b(0?[0-9][0-9][0-9])\b", ErrorMessage = "BEI Code should be Only three Chracter Length!")]

I need to look for Empty string also in this validation

thanks

1 Answer 1

2

Why not check for the empty string using a Required validation attribute alongside your RegularExpression attribute?

[Required(ErrorMessage = "This field is required")]
[RegularExpression(@"\b(0?[0-9][0-9][0-9])\b", 
                  ErrorMessage = "BEI Code should be Only three Chracter Length!")]
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Jamie, yes I tried that but some reason my Required filed is not working properly.. Instead of This field is required I am getting the message for Empty '{PropertyName}' should not be Empty.. I dont know why I am getting this message?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.