Im using c# and I need to be able to check that the user selects a title from the dropdown list. How would I set the regex to check that the selection starts with M, the values in my dropdown list are Mr, Ms and Mrs. This regex would be used in my customvalidator in Visual Studio 2008 3.5 framework.
Edit: Let me rephrase it, What do i type in my ValidationExpression field for my RegularExpressionValidator Validation type.
To answer your question:
That said, it really doesn’t sound like a job for regular expressions. You could use
StartsWith, which is more sane, but what happens when “Mike Smith” registers, and doesn’t select a title?If you want to ensure that a user selected your specific value, then validating the selected value is really what you should do here. Feel free to post more information if that scenario isn’t possible.
On a side note, I can’t resist posting this quote:
Edit: I missed your edit before I posted. You would be better off using a
RequiredFieldValidatorand setting InitialValue to “Select A Title”.