RadNumericTextBox issue when entering more than 15 digits number

2 posts, 0 answers
  1. Manoj
    Manoj avatar
    26 posts
    Member since:
    Feb 2012

    Posted 07 Aug 2014 Link to this post

    I need to display the large number in exponential notation format.

    When I enter more than 15 digit number which is "12345678901234567890" into the RadNumericTextBox

    Value automatically gets rounded as 12345678901234560000.(Zero at the end) which is wrong.

    When I enter more than 21 digits number "1234567890123456789012"
    then the value gets displayed as "1.234567890123457e+21" which is working perfectly

    So the problem is in between the range 16 - 21 Digits. 

    Please help to resolve this problem.

    Using IE.9,Chrome,Firefox
    Telerik version : 2014.1.416.40

    My Code
    <telerik:RadNumericTextBox Width="100px" ID="txtTest" EmptyMessage="Test" ShowSpinButtons="false" DisplayText="" Type="Number"
                                    runat="server" InvalidStyleDuration="100">
                                    <NumberFormat AllowRounding="false" GroupSeparator="" DecimalDigits="15"   KeepNotRoundedValue="true" />
                                    <ClientEvents OnKeyPress="keyPress" OnValueChanged="valueChanged"  />
    Telerik.Web.UI.RadNumericTextBox.prototype._compileRegEx = function () {
                            var regexDecimalSeparator = this.get_numberFormat().DecimalSeparator == "." ? "\\." : this.get_numberFormat().DecimalSeparator;
                            this._acceptRegExp = new RegExp("[e0-9" + regexDecimalSeparator + this.get_numberFormat().NegativeSign + "]{1}");
                            this._rejectRegExp = new RegExp("[^e0-9" + regexDecimalSeparator + this.get_numberFormat().NegativeSign + "]{1}", "g");
                            this._decimalReplaceRegExp = new RegExp(regexDecimalSeparator, "g");
                        var orgNegativeSign = "";
                        function keyPress(sender, args) {
                            if (args.get_keyCode() == 45) {
                                orgNegativeSign = sender.get_numberFormat().NegativeSign;
                                sender.get_numberFormat().NegativeSign = "~";
                        function valueChanged(sender, args) {
                            if (orgNegativeSign != "") {
                                sender.get_numberFormat().NegativeSign = orgNegativeSign;
                                orgNegativeSign = "";
  2. Viktor Tachev
    Viktor Tachev avatar
    1438 posts

    Posted 12 Aug 2014 Link to this post

    Hi Manoj,

    The RadNumericTextBox control supports numbers that are between -2^46 and 2^46. If you enter a number that is outside that range abnormalities in the behavior of the control could be observed.

    This said, would you elaborate more on the scenario that you would like to implement? Are you performing calculations with a 21 digit number or it is only stored and used somewhere as is?

    In case you do not need to perform calculations with the number and its length is fixed to 21 digits you could use a RadMaskedTextBox for the number.

    Viktor Tachev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  3. DevCraft R3 2016 release webinar banner
Back to Top