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

Currency Format Lost after Cancel Event

1 Answer 32 Views
Input
This is a migrated thread and some comments may be shown as answers.
License
Top achievements
Rank 1
License asked on 05 Jun 2015, 07:31 PM

I have some Numeric Textboxes where I am using the OnValueChanging client event to do some validation and when I utilize the eventArgs.set_cancel(true) function, the value is reverted back to the old value, however the currency format is lost when I exit the field. If I reenter the field and exit again, the dollar sign will display properly.

 

Here is a sample of the script: 

function onValueChanging(sender, eventArgs) {
    var value = eventArgs.get_newValue();
 
    var txtTest = $find("<%= txtTest.ClientID %>");
 
    if ((value < sender.get_minValue()) || (value > txtTest.get_value())) {
        alert('Value must be a non-negative number and cannot exceed txtTest');
        eventArgs.set_cancel(true);
    }
}

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 10 Jun 2015, 11:49 AM
Hello Robert,

Thank you for reporting this issue with the RadNumericTextBox.

I will forward the problem to our developers team, so they could further investigate it. As a temporary workaround you can use the following code that forces the control to format the value:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function onValueChanging(sender, eventArgs) {
            var value = eventArgs.get_newValue();
 
            var txtTest = $find("<%= txtTest.ClientID %>");
 
            if ((value < sender.get_minValue()) || (value > txtTest.get_value())) {
                alert('Value must be a non-negative number and cannot exceed txtTest');
                eventArgs.set_cancel(true);
                setTimeout(function () {
                    sender.focus();
                    sender.blur();
                })
            }
        }
    </script>
</telerik:RadCodeBlock>
 
<telerik:RadNumericTextBox runat="server" ID="txtTest" Value="5"></telerik:RadNumericTextBox>
 
<telerik:RadNumericTextBox runat="server" Type="Currency" MinValue="0" ClientEvents-OnValueChanging="onValueChanging"></telerik:RadNumericTextBox>

For bringing the issue to our attention you will find your Telerik Points updated.

Please excuse us for any inconvenience caused by this.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
 
Tags
Input
Asked by
License
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or