Pasting comma into Number Input TextBox

4 posts, 0 answers
  1. appdev
    appdev avatar
    1 posts
    Member since:
    Aug 2009

    Posted 23 Sep 2008 Link to this post

    Hi,

    When I paste the value "12,234" into the Numeric Input box (see below), the control thinks that the comma is a decimal place. This is very confusing for our users, as they have to remove the decimal place. How can I fix this?

    Thanks,
    Tim

    <telerik:RadNumericTextBox ID="txtSalaryTo" runat="server" ShowSpinButtons="true">  
        <NumberFormat DecimalDigits="0" DecimalSeparator="." GroupSeparator="," GroupSizes="3" AllowRounding="false" /> 
        <IncrementSettings Step="1000" /> 
        <ClientEvents OnKeyPress="KeyPress_Salary" /> 
    </telerik:RadNumericTextBox> 

  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 26 Sep 2008 Link to this post

    Hello Tim,

    You can test this sample approach:
    function ValueChanging(sender, args) 
        var newValue = ""
        var oldValue = sender.get_textBoxValue(); 
        var result = oldValue.split(','); 
        for (var i = 0; i < result.length; i++) 
        { 
            newValue += result[i]; 
        } 
        args.set_newValue(newValue); 

    <telerik:RadNumericTextBox ID="txtSalaryTo" runat="server" ShowSpinButtons="true"
        <NumberFormat DecimalDigits="0" DecimalSeparator="." GroupSeparator="," GroupSizes="3" 
            AllowRounding="false" /> 
        <IncrementSettings Step="1000" /> 
        <ClientEvents OnKeyPress="KeyPress_Salary" OnValueChanging="ValueChanging" /> 
    </telerik:RadNumericTextBox> 

    Regards,
    Daniel
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. George Perley
    George Perley avatar
    2 posts
    Member since:
    Mar 2010

    Posted 22 Mar 2010 Link to this post

    We are having the same problem as the original poster, and we implemented the solution suggested by Daniel and it works great. However, we use the RadNumericTextBox on a lot of places in our application, and we were hoping to find a more global solution. We put the function in the javascript file that is used for all pages, but that still leaves us with having to edit every RadNumericTextBox control's settings individually.

    I tried putting the ClientEvents-OnValueChanging setting into a custom skin, but we get a compile error:

    Literal content ('<telerik:RadNumericTextBox ClientEvents-OnValueChanging="ValueChanging" />') is not allowed within a 'skin file'.

    Is there a global way to accomplish what we are trying to do here?

    George
  4. George Perley
    George Perley avatar
    2 posts
    Member since:
    Mar 2010

    Posted 22 Mar 2010 Link to this post

    After doing a little more research I realized I had left the 'runat="server"' out of the entry in the skin file. That was what was actually causing the error, not the ClientEvents setting itself. Everything works fine now and we have our global solution. Problem solved.

    George
Back to Top