Currency Format Lost after Cancel Event

2 posts, 0 answers
  1. Mike
    Mike avatar
    41 posts
    Member since:
    Aug 2011

    Posted 05 Jun 2015 Link to this post

    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);
        }
    }

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1803 posts

    Posted 10 Jun 2015 Link to this post

    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
     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top