Articles in this section
Category / Section

How to Allow Decimals Without Any Limit in JavaScript NumericTextBox?

1 min read

This article explains how to allow decimals without any limit in JavaScript NumericTextBox. The NumericTextBox component specifies the number precision applied to the textbox value on the textbox focused state. So, you can customize the options to type decimal values without any limits using the focusout event of NumericTextBox  JavaScript NumericTextBox feature tour. The following code sample demonstrate how to allow decimal values without any limit.

 

<ejs-numerictextbox validateDecimalOnType='false' id='numeric' value='54' max='100' [decimals]='' width='270' maxlength='20' currency="USD" format="$#.#" (focusout)="changeValue($event)"></ejs-numerictextbox>

 

[focusout event for NumericTextBox]

public changeValue(args) {
    var value = args.target.getAttribute("aria-valuenow");
    var length = value.split('.')[1] && value.split('.')[1].length;
    var format = "$#.";
    for (var a = 0; a < length; a++) {
      format = format + "#";
    }
    var obj = args.target.ej2_instances[0];
    obj.format = format;
    obj.dataBind()
  }

 

Refer to the working sample for additional details and implementation: Sample



 

Note: Our NumericTextBox component uses the JavaScript Number object, which loses decimals after the 16th digit, so it behaves like a normal TextBox. You can find more information about Number objects in the following documentation. To overcome this limitation, define the max value of the NumericTextBox to be less than a 16-digit number.

 

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number 

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number 



Conclusion

We hope you enjoyed learning about how to allow decimals without any limit in the JavaScript NumericTextBox.

You can refer to our JavaScript NumericTextBox feature tour page to know about its other groundbreaking feature representations. You can also explore our JavaScript NumericTextBox documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsBoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied