Replacing . with , ; or insertnig a , from javascript

2 posts, 0 answers
  1. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 16 Dec 2009 Link to this post

    Hi,

    I have been having some trouble with the following:

    My application has a number of RadNumericTextboxes, in which decimal numbers are entered. My current (and desired) culture settings use a ',' as a decimal separator. My users want to be able to use the '.' on their numeric pad for entering it (much like calc.exe does, it accepts both ',' and '.' and enters a ',').
    This does not work with the control and I don't think there is a direct way of setting this option.
    If there is an option, please tell me.

    As I expect there is no such option, I have written a piece of javascript to handle the OnKeyPress event:
    function Dot2Comma(sender, eventArgs) { 
          var c = eventArgs.get_keyCharacter(); 
          if (c == '.') { 
            eventArgs.set_cancel(true); 
            sender.Value = sender.Value + ','; 
          } 
        } 

    It goes wrong on the line "sender.Value = sender.Value + ',';" is there any way of adding the ',' from javascript?

    Would it be possible to add this functionality in a later version of the telerik radcontrols?
  2. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 16 Dec 2009 Link to this post

    Hi Datamex,

    Please use sender._textBoxElement.value instead of sender.Value.
    "sender" is the client control instance (not a textbox element) and does not have a "value" property. Consult the control's API if necessary.


    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top