We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to enter data that starts with 0 into the ejs-numerictextbox.

In "ejs-numerictextbox" or "ejs-textbox," the user should only be able to enter numbers. It can't be a prime number, I'm referring to a dot. Also, it can't be negative numbers. It can only be numbers. There's another condition. It should be possible to start with zero. For example, "000228" should also be possible. Currently, when a user enters 000228 in the ejs-numerictictextbox and exits the cursor, 000 disappears, leaving only 228 remaining.


I can't be the only one going through this. Please tell me how


1 Reply

KP Kokila Poovendran Syncfusion Team April 3, 2024 07:58 AM UTC

Hi ,


Greetings from Syncfusion support!


The behavior you're observing, where leading zeros are removed when focusing out of the NumericTextBox component, is due to the default behavior of the component treating the input as a numeric value.


When you enter "000228", the component interprets it as the number 228 and formats it accordingly. By default, the component formats numeric values with two decimal places, hence "228" gets formatted to "228.00".


To achieve the behavior you described, we recommend using our MaskedTextBox component instead. This component allows you to specify a mask pattern that controls the input format. 


For further guidance and implementation details, please refer to our documentation on the MaskedTextBox component:

https://ej2.syncfusion.com/angular/documentation/maskedtextbox/getting-started


You can also explore the demo site for a live demonstration of the MaskedTextBox component:

https://ej2.syncfusion.com/angular/demos/#/bootstrap5/maskedtextbox/default


If you have any further questions or need assistance with implementation, feel free to ask.



Documentation: 
Demo: 


Loader.
Live Chat Icon For mobile
Up arrow icon