.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

A quicky - CompareValidator

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :ASP.Net

Hi - if I use a CompareValidator on 2 password boxes, the user types their password into Textbox1 and then when they click in TextBox2 the "Passwords dont match" message appears. Now - obviously the passwords dont match as the 2nd is blank.

How do I get the CompareValidator to only compare the passwords when the user clicks out of the second textbox - when we actually have some data to compare?


View Complete Post

More Related Resource Links

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

CompareValidator - double

<asp:CompareValidator ID="CompareValidatorAmountDepositMin" runat="server"        ErrorMessage="Znesek vplacila je premajhen!" ControlToValidate="AmountDeposit" Operator="GreaterThanEqual"        ValidationGroup="ErrormessageValidationGroup" ValueToCompare="1" Type="Double" Display="Dynamic">        <asp:Image ID="Image13" runat="server" ImageUrl="~/Images/warning.png" ImageAlign="TextTop" /></asp:CompareValidator><asp:CompareValidator ID="CompareValidatorAmountDepositMax" runat="server"        ErrorMessage="Znesek vplacila je prevelik!" ControlToValidate="AmountDeposit" Operator="LessThanEqual"        ValidationGroup="ErrormessageValidationGroup" ValueToCompare="10000" Type="Double" Display="Dynamic">        <asp:Image ID="Image14" runat="server" ImageUrl="~/Images/warning.png" ImageAlign="TextTop" /></asp:CompareValidator>The problem is that it does not work if I write "10.5

FieldTemplateUserControl CompareValidator - Localize DataType Check ErrorMessage


 Just a (simple) question, whom I don't have a simple answer for:

Why the CompareValidator that comes with some of the FieldTemplateUserControls cannot be localized/customized (in its error message) using the usual ValidationAttribute mechanism (ie. by exploiting an enhanced version of the DataTypeAttribute)?
That is curious (at least).

Thanks in advance.

Problem with future date validation using CompareValidator


Realy simple aspx page:

<asp:TextBox ID="txtExpireDate" runat="server" Width="78px" MaxLength="10" ></asp:TextBox>


ASP.NET CompareValidator


Hi Experts,

I have page Default.aspx, on that I have place textbox. For that textbox, I have pleace CompareValidator as:

<asp:CompareValidator ID="CmpValBillingTelephone" runat="server" Display="None" ControlToValidate="txtBillingPhone" Type="Integer" Operator="DataTypeCheck" ErrorMessage="<b>Required Number</b><br />Valide Telephone."                                                             SetFocusOnError="true" ValidationGroup="OrderDetailGroup"></asp:CompareValidator>
<AJAX:ValidatorCalloutExtender runat="server" ID="ValidatorTelephone" TargetControlID="CmpValBillingTelephone" HighlightCssClass="validatorCalloutHighlight" Enabled="True"></AJAX:ValidatorCalloutExtender>

This works fine while checking the entered value as Integer. But the problem is that, when I called ModalPopUp from the same page on the background the above validator will calls (Behind the ModalPopUp.) I want t

Job Schedule Quicky


Hi All,

I have a job scheduled to run between 10:00 and 19:00 every 3 hours (10:00, 13:00, 16:00, 19:00) but it does not run at 19:00. Does anybody know of any official documentation to say that this is the case as I cannot find any. Or is my interpretation on how scheduling works incorrect. I know to test I can just increase the time a little but just curious.

Thanks for taking the time to read this.


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend