title: How do I validate a selected value in a DropDownList?
body: <p>I want the user to make a valid selection in a <code>DropDownList</code>, but I don't want to present any selection as the default so the default selected value is <code>-- Select --</code>.  I am using a <code>RegularExpressionValidator</code> to only accept selected values that contain a literal comma (since the valid items are formatted <code>LastName, FirstName</code>).  </p>
  
  <p>However, I am perplexed as to how to get the validator to look for the Selected value!  I'd really rather NOT make this a server-level validation, and if possible I'd like to keep it as simple as a Regex Validator.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>&lt;asp:DropDownList ID="ddNames" runat="server"&gt;
  &lt;/asp:DropDownList&gt;
  &amp;nbsp;
  &lt;asp:RegularExpressionValidator ID="RegexValidator" runat="server" 
      ControlToValidate="ddNames" ValidationExpression=".*\,.*" 
      ErrorMessage="Select a Valid User"&gt;
  &lt;/asp:RegularExpressionValidator&gt;
  </code></pre>
  
  <p>The dropdown values are:</p>
  
  <pre><code>-- Select --
  Smith, John B
  Jones, Bill
  Wilkinson, Harmony
  Hull, Cordell
  Hill, Faith
  </code></pre>
  
  <p>Is there a way to aim the validator at the SelectedValue?  As shown, the Validator seems not to be seeing any of the values in the control.</p>