Give a sample code snippet for ASP.NET CompareValidator server control?

Posted by Tripati_tutu under HTML 5 category on | Points: 40 | Views : 2812
Normally in case of creating a ID, it is asking to enter password two times that is one is password and another one is confirm password. Here your password and confirm password must be same. For this kind of requirement you can use Compare validator. It will compare both the textboxes whether both are same or not.

Sample Code:
<form id="Form1" runat ="server" action ="" >
Enter Your Username and Password in the textboxes: <br />
UseName: <asp:TextBox ID ="txtUname" runat ="server" /><br />
Password: <asp:TextBox ID ="txtPwd" runat ="server" TextMode ="Password" /><br />
Confirm Pwd: <asp:TextBox ID ="txtCpwd" runat ="server" TextMode ="Password" />
<br /><br />
<asp:Button ID="Button1" Text ="submit" runat ="server" />
<br />
<asp:CompareValidator ID ="cvPwd" runat ="server" ControlToValidate ="txtCpwd" ControlToCompare ="txtPwd" CssClass ="AlertText" Display ="Dynamic" EnableClientScript ="true" >
<img src ="image1.JPG" alt ="" />
Both Password must be same!

Comments or Responses

Login to post response