Issue with radnumeric textbox not allow decimal point and negative character

2 posts, 1 answers
  1. Jiju
    Jiju avatar
    57 posts
    Member since:
    Jul 2011

    Posted 28 Jun 2013 Link to this post


    i am using radnumeric text box in my page and i used following javascript function to avoid both decimal point and negative symbol

    function DecimalKeyPress(sender, args) {
                    var keyCharacter = args.get_keyCharacter();

                    if (keyCharacter == sender.get_numberFormat().DecimalSeparator ||
            keyCharacter == sender.get_numberFormat().NegativeSign) {

    But there seems to be an issue with Firefox as delete key is not working. We found that both delete and decimal key return the same key character as 46. It works with all other browsers.

    How can i fix this issue.

  2. Answer
    Viktor Tachev
    Viktor Tachev avatar
    2480 posts

    Posted 03 Jul 2013 Link to this post

    Hello Jiju,

    Thank you for contacting Telerik support.

    The OnKeyPress client side event is fired only in Firefox when a non-printable character key is pressed. The "." key has a keyCode = 0 and charCode = 46. The "Delete" key has a keyCode= 46 and charCode = 0.

    You could use the get_domEvent() function to get the charCode for the pressed key. If it is equal to 0 it means that a non-printable key (del, home, end, etc.) was pressed.

    You could modify the Javascript function you have a little to get the result you are looking for. The function would look similar to this:

    function DecimalKeyPress(sender, args) {
        var keyCharCode = args.get_domEvent().rawEvent.charCode;
        if (keyCharCode == sender.get_numberFormat().DecimalSeparator.charCodeAt() || keyCharCode == sender.get_numberFormat().NegativeSign.charCodeAt()) {

    Let me know if this modification is working for you.

    Viktor Tachev
    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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top