Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > NumericTextBox > Restrict number of decimal places to 2 during input
Telerik MVC Extensions are no longer supported (see this page for reference). In case you have inquiries about Kendo UI Complete for ASP.NET MVC, post them in the pertinent Kendo UI forums.

Not answered Restrict number of decimal places to 2 during input

Feed from this thread
  • BT avatar

    Posted on Dec 8, 2011 (permalink)

    For CurrencyBox, is there any way to restrict the number of decimal places a user can enter during input?

    For e.g. I have a Unit Price field that I only want to store up to 2 decimal places in the database.
    When using CurrencyBox, it allowed my users to enter any number of decimal places then round the value to 2 decimal places.
    What I want is to just prevent the user to enter more than 2 decimal places. 

    Is this possible with CurrencyBox?

  • Georgi Krustev Georgi Krustev admin's avatar

    Posted on Dec 9, 2011 (permalink)

    Hello Bt,

     
    The Numeric/Currency/Percentage/IntegerTextBox does not restrict the user input while they types. Nevertheless, as you mentioned, once the user blur the input the component will round the number.
    One possible solution is to wire the keydown event of the input element end prevent the input if the typed number has more than 2 decimal digits. Other option is to set the maxlength of the input element.

    Regards,
    Georgi Krustev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > NumericTextBox > Restrict number of decimal places to 2 during input
Related resources for "Restrict number of decimal places to 2 during input"

ASP.NET MVC NumericTextBox Features  |  Documentation  |  Demos  |  Telerik TV ]