Click here to Skip to main content
15,912,977 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ,,
if i want to compare two textboxes by using custom validator,what is the code i dont know exactly please tell me the code as soon as possible
for example am taking password in one textbox and other is retype password,i want comapre both the textboxes please tell me code..........



Thanks In Advance..........
Posted

Why don't you use CompareValidator?
 
Share this answer
 
XML
<table border="0" bgcolor="#b0c4de">
   <tr valign="top">
     <td colspan="4"><h4>Compare two values</h4></td>
   </tr>
   <tr valign="top">
     <td><asp:TextBox id="txt1" runat="server" /></td>
     <td> = </td>
     <td><asp:TextBox id="txt2" runat="server" /></td>
     <td><asp:Button Text="Validate" runat="server" /></td>
   </tr>
</table>
<br />
<asp:CompareValidator
id="compval"
Display="dynamic"
ControlToValidate="txt1"
ControlToCompare="txt2"
ForeColor="red"
BackColor="yellow"
Type="String"
EnableClientScript="false"
Text="Validation Failed!"
runat="server" />
 
Share this answer
 
you can use compare validator and set the controltocompare as the id of the password textbox and controltovalidate as the id of the confirm password textbox. operator should be equal or something similar.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900