title: ASP:NET Confirm Password field
body: <p>Im creating a simple registration form in asp.net. 
  Here's my problem:
  If my confirm passwordfield is empty it still submits the form. I'm using compareToValidate do I also need to use a requiredvalidator. I'm new to asp.net but shouldnt the comparevalidator generate an error if lets say password is 123 and the confirmpassword is empty.</p>
  
  <pre><code>        &lt;fieldset&gt;
         &lt;legend&gt;Enter your data&lt;/legend&gt;
         &lt;table&gt;
          &lt;tr&gt;
         &lt;td align="right"&gt;User Name :&lt;/td&gt;
         &lt;td&gt;&amp;nbsp;&lt;/td&gt;
           &lt;td align="left"&gt;
          &lt;asp:TextBox ID="tbUsername" runat="server"&gt;&lt;/asp:TextBox&gt;
      &lt;asp:RequiredFieldValidator ID="rfvUserName" runat="server" 
          ControlToValidate="tbUsername" 
          CssClass="ValidationError"
          ErrorMessage="&amp;laquo; (Required)"
          ToolTip="User Name is a REQUIRED field"
          &gt;&lt;/asp:RequiredFieldValidator&gt;
          &lt;/td&gt;
  &lt;/tr&gt;`enter code here`
  &lt;tr &gt;
  &lt;td align="right"&gt;Password&amp;nbsp;:&amp;nbsp;&lt;/td&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;td align="left"&gt; 
      &lt;asp:TextBox ID="tbPassword" runat="server" TextMode="Password"&gt;&lt;/asp:TextBox&gt;
      &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
       ErrorMessage="&amp;laquo; (Required)" 
       ControlToValidate="tbPassword"
       CssClass="ValidationError"
  
      ToolTip="Password is a REQUIRED field"
      &gt;&lt;/asp:RequiredFieldValidator&gt;
  &lt;/td&gt;
  
  &lt;/tr&gt;
  &lt;tr &gt;
  &lt;td align="right"&gt;Confirm Password&amp;nbsp;:&amp;nbsp;&lt;/td&gt;
  &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;td align="left"&gt; 
      &lt;asp:TextBox ID="ConfirmPass" runat="server" TextMode="Password"&gt;&lt;/asp:TextBox&gt;
       &lt;asp:CompareValidator ID="CompareValidator1" runat="server" 
       ControlToValidate="ConfirmPass"
       CssClass="ValidationError"
       ControlToCompare="tbPassword"
       ErrorMessage="No Match" 
       ToolTip="Password must be the same" /&gt;
  
  &lt;/td&gt;
  
  &lt;/tr&gt;
  </code></pre>
  
  <p></p>