I am creating a simple registration form in asp.net. Here is my problem: If my password confirmation field is empty, it submits a form anyway. I use compareToValidate, also I need to use the required validator. I am new to asp.net, but should not refer to comparevalidator if it allows me to say that the password is 123 and the confirmation password is empty.
<fieldset> <legend>Enter your data</legend> <table> <tr> <td align="right">User Name :</td> <td> </td> <td align="left"> <asp:TextBox ID="tbUsername" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="rfvUserName" runat="server" ControlToValidate="tbUsername" CssClass="ValidationError" ErrorMessage="« (Required)" ToolTip="User Name is a REQUIRED field" ></asp:RequiredFieldValidator> </td> </tr>`enter code here` <tr > <td align="right">Password : </td> <td> </td> <td align="left"> <asp:TextBox ID="tbPassword" runat="server" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="« (Required)" ControlToValidate="tbPassword" CssClass="ValidationError" ToolTip="Password is a REQUIRED field" ></asp:RequiredFieldValidator> </td> </tr> <tr > <td align="right">Confirm Password : </td> <td> </td> <td align="left"> <asp:TextBox ID="ConfirmPass" runat="server" TextMode="Password"></asp:TextBox> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="ConfirmPass" CssClass="ValidationError" ControlToCompare="tbPassword" ErrorMessage="No Match" ToolTip="Password must be the same" /> </td> </tr>
Dynamiite
source share