This is a migrated thread and some comments may be shown as answers.

RadNumericTextBox and CompareValidator Always fails with Currency

3 Answers 192 Views
Input
This is a migrated thread and some comments may be shown as answers.
Joseph Roberts
Top achievements
Rank 1
Joseph Roberts asked on 17 Jul 2009, 02:46 PM
I have a RadNumericTextBox, set to Currency Type, and a regular text box.  I also have a CompareValidator that compares the RadNumericTextBox and the regular TextBox.  I initialze each text box with the same value.  Both Boxes are formatted as currence and the CompareValidator is set to Currency.  No matter what I put for an input in my RadNumericTextBox, the comparevalidator fails.  I'm doing a LessThanEqual comparison. 

Does anyone have any ideas?

Thanks

3 Answers, 1 is accepted

Sort by
0
ManniAT
Top achievements
Rank 2
answered on 20 Jul 2009, 09:30 AM

Hi,

I'm not sure how you got a "normal textbox in currency mode" - but RadNumericTextBox (even when set to currency) works also with double validation.
That works: (it show "OK" when the validator fail :)):

<telerik:RadNumericTextBox ID="rntbTest" runat="server" Type="Currency" Value="1" /> 
<asp:TextBox ID="tbCheck" runat="server" Text="1" /> 
<asp:CompareValidator runat="server" ControlToCompare="tbCheck"  ControlToValidate="rntbTest" Type="Double" MinimumValue="3" MaximumValue="10" Text="OK"  Operator="LessThanEqual" /> 
    <asp:Button ID="btnCeck" runat="server" Text="Check" /> 
</asp:Content> 
 

If this doesn't help you - please provide a snippet like this to show what you do.

Regards

Manfred
0
Joseph Roberts
Top achievements
Rank 1
answered on 21 Jul 2009, 01:22 PM

Thanks for your response.  Here is how I'm set up...

 

 

 

 

<telerik:RadInputManager ID="RadInputManager1" runat="server">  
<telerik:NumericTextBoxSetting BehaviorID="CurrencyBehavior" Type="Currency" DecimalDigits="2">  
<ClientEvents OnKeyPress="Input_DisabledNegativeSign" /> 
<TargetControls> 
<telerik:TargetInput ControlID="trasferAmtTxt" /> 
</TargetControls> 
</telerik:NumericTextBoxSetting> 
</telerik:RadInputManager> 
 
<asp:TextBox ID="trasferAmtTxt" runat="server"></asp:TextBox> 
<asp:TextBox ID="trasferAmt2Txt" runat="server" Visible="False"></asp:TextBox> 
<asp:CompareValidator ID="transferAmtVal" runat="server" ControlToCompare="trasferAmt2Txt" 
ControlToValidate="trasferAmtTxt" Display="None" ErrorMessage="8" Operator="LessThanEqual" 
Text="The Transfer Amount must be less than or equal the transaction amount." Type="Currency"></asp:CompareValidator> 
 


When I said that my regular text box was "currency" I just meant that the number was formatted using the string format methods .ToString("$#,##0.00").

The page checks if the Page is Valid on postback and will then show the contents of the Text field of my Validators if an error occurs on the page and the Validator is invalid. 

Thanks for the help.
Joe

 

0
ManniAT
Top achievements
Rank 2
answered on 21 Jul 2009, 02:32 PM
OK,

I understand what you mean.
First a fault in your app - if you really format you currency "$##,##,,," you are missing a blank for "real currency format".

But - anyhow - neither double nor currency validation works when you compare "text with currency symbols".

I changed your example a bit
made the second box visible - otherwise it is not rendered
Added a "true" RadNumericTextBox.
<telerik:RadInputManager ID="RadInputManager1" runat="server">  
    <telerik:NumericTextBoxSetting BehaviorID="CurrencyBehavior" Type="Currency" DecimalDigits="2">  
        <ClientEvents OnBlur="OnCheckVal" /> 
        <TargetControls> 
            <telerik:TargetInput ControlID="trasferAmtTxt" /> 
        </TargetControls> 
    </telerik:NumericTextBoxSetting> 
</telerik:RadInputManager> 
Values in other boxes must be lesser than this:  
<asp:TextBox ID="trasferAmt2Txt" runat="server" Text="€ 33"></asp:TextBox> 
<asp:RequiredFieldValidator runat="server" ControlToValidate="trasferAmt2Txt" Text="Value needed" /><br /> 
Enter only a number (no currency symbol) - and RadNumeric will work!!<br /> 
<br /> 
<hr /> 
Textbox with manager:  
<asp:TextBox ID="trasferAmtTxt" runat="server"></asp:TextBox> 
<asp:RequiredFieldValidator runat="server" ControlToValidate="trasferAmtTxt" Text="Value needed" /> 
<br /> 
Validator Currency:  
<asp:CompareValidator ID="transferAmtVal" runat="server" ControlToCompare="trasferAmt2Txt" ControlToValidate="trasferAmtTxt" ErrorMessage="8" Operator="LessThanEqual" Text="The Transfer Amount must be less than or equal the transaction amount." Type="Double"></asp:CompareValidator><br /> 
Validator double:  
<asp:CompareValidator runat="server" ControlToCompare="trasferAmt2Txt" ControlToValidate="trasferAmtTxt" ErrorMessage="8" Operator="LessThanEqual" Text="The Transfer Amount must be less than or equal the transaction amount." Type="Double"></asp:CompareValidator> 
<br /> 
<hr /> 
RadNumericTextbox:  
<telerik:RadNumericTextBox ID="rntbOther" runat="server" Type="Currency">  
</telerik:RadNumericTextBox> 
<asp:RequiredFieldValidator runat="server" ControlToValidate="rntbOther" Text="Value needed" /> 
<br /> 
Validator Currency:  
<asp:CompareValidator ID="transferAmtVal2" runat="server" ControlToCompare="trasferAmt2Txt" ControlToValidate="rntbOther" ErrorMessage="8" Operator="LessThanEqual" Text="Currency at work." Type="Currency"></asp:CompareValidator> 
<br /> 
Validator Double:  
<asp:CompareValidator ID="transferAmtVal3" runat="server" ControlToCompare="trasferAmt2Txt" ControlToValidate="rntbOther" ErrorMessage="8" Operator="LessThanEqual" Text="Double at work." Type="Double"></asp:CompareValidator> 
<br /> 
<hr /> 
Pure Textbox:  
<asp:Textbox ID="txtPure" runat="server" Type="Currency" Text="€ 11" /><asp:RequiredFieldValidator runat="server" ControlToValidate="txtPure" Text="Value needed" /> <asp:Textbox ID="txtPureOther" runat="server" Type="Currency" Text="€ 12" /> 
<asp:RequiredFieldValidator runat="server" ControlToValidate="txtPureOther" Text="Value needed" /> 
<br /> 
Validator Currency:  
<asp:CompareValidator runat="server" ControlToCompare="txtPure" ControlToValidate="txtPureOther" ErrorMessage="8" Operator="LessThanEqual" Text="Currency at work." Type="Currency"></asp:CompareValidator> 
<br /> 
Validator Double:  
<asp:CompareValidator runat="server" ControlToCompare="txtPure" ControlToValidate="txtPureOther" ErrorMessage="8" Operator="LessThanEqual" Text="Double at work." Type="Double"></asp:CompareValidator> 
<br /> 
<asp:Button ID="btnSubmit" runat="server" Text="Start Validation" /><br /> 
<href="CompVali.aspx">Refresh</a> 
What does it proof:
a.) as long as you use currency symbols nothing works!!!
b.) when you enter (in the "compared to" -- first TextBox) a double "something" works:
---The "true RadNumericTextBox" works
---The Manager generated Textbox does NOT work!!!

To proof the concept I've added two textboxes on the end (first must be greater).
They also work only if you do not enter currency symbols!!!

So the conclusion:
a.) RadNumericTextBox works as expected!
b.) Manager generated NumericTextBox is somehow different

Last not least - I added a blur script - it looks like this:
<script type="text/javascript">  
        function OnCheckVal(sender, args) {  
            var vA = sender._radInputExtender.get_value();  
        }  
    </script> 
And it get's the "pure value" as number.

To make the things easier - I put the test onto my test site http://www.pp-p.net/CompVali.aspx
Regards

Manfred
Tags
Input
Asked by
Joseph Roberts
Top achievements
Rank 1
Answers by
ManniAT
Top achievements
Rank 2
Joseph Roberts
Top achievements
Rank 1
Share this question
or