How to validate a confirmation password for the match?

Posted by Raja under ASP.NET category on | Views : 7332
We can use CompareValidator control to validate the confirmation password to check if both password entered by user is same or not (Generally used to register a user in the website).

Password:  <asp:TextBox id="TextBox1" runat="server"  TextMode="Password"></asp:TextBox>
Confirm Password: <asp:TextBox id="TextBox2" runat="server" TextMode="Password"></asp:TextBox>

<asp:CompareValidator id="CompareValidator1"
runat="server" ErrorMessage="Passwords do not match!"
ControlToCompare="TextBox1" ></asp:CompareValidator>

In this case if user will not enter same password in both box, the form will not be submitted.

Comments or Responses

Login to post response