I want the user to make the right choice in DropDownList , but I do not want to represent any default choice, so the default value -- Select -- . I use RegularExpressionValidator to accept only selected values ββcontaining a literal comma (since the actual elements are formatted LastName, FirstName ).
However, I wonder how to get the validator to look for the Selected value! I would prefer NOT to make this confirmation at the server level, and if possible, I would like to keep it as simple as the Regex Validator.
Here is the code:
<asp:DropDownList ID="ddNames" runat="server"> </asp:DropDownList> <asp:RegularExpressionValidator ID="RegexValidator" runat="server" ControlToValidate="ddNames" ValidationExpression=".*\,.*" ErrorMessage="Select a Valid User"> </asp:RegularExpressionValidator>
Outlying Values:
-- Select -- Smith, John B Jones, Bill Wilkinson, Harmony Hull, Cordell Hill, Faith
Is there any way to target the validator on SelectedValue? As shown, the validator does not seem to see any values ββin the control.
source share