RddNumeric Textbox - Onblur event triggering on Readonly

3 posts, 0 answers
  1. Rhbkv
    Rhbkv avatar
    30 posts
    Member since:
    Jun 2012

    Posted 11 Jan 2013 Link to this post

    Hi,
    We are using RadnumericTextbox to hold numeric value. We have formatText method on Onblur event to format the entered value.
    On Form load, we have set  the RadnumericTextbox as readonly (since we do not want enabled=false). Onblur event was not triggering when textbox is readonly and did not show formated text as 0.00 (since textbox is empty) till we upgrade to telerik version 2012.2.912.40
    After upgrade, RadnumericTextbox is triggering onblur event even if it is readonly.
    Is there any way to check whether RadnumericTextbox is readonly or not in Javascript?
    Since we have many RadnumericTextbox in the form we have used generic javascript method to format a text as below

     

     

    function FormatText(sender, args) {

     

     

     

    var num  = sender.get_value();

     

     

     

    if (num == "" || num == "undefined") {

     

    num = 0.00

    }

     

     

    var result = num.toFixed(2);

     

    sender.set_value( result);

    sender._textBoxElement.value = num.toFixed(2);

    }


    In this method, is it possible to check whether "Sender" is readonly or not to avoid formating?
    Thanks
  2. MasterChiefMasterChef
    MasterChiefMasterChef avatar
    152 posts
    Member since:
    Jan 2013

    Posted 15 Jan 2013 Link to this post


    Hi Rhbkv,

    It would be difficult to check the status of your RadNumericTextBox in Javascript, but it would be possible to do in C# in the event handler. You would just need to change the type of sender from Object to RadNumericTextBox. Hopefully this will help with what you are trying to do.

    protected void RadNumericTextBox1_OnBlur(RadNumericTextBox sender, EventArgs e)
    {
        if (sender.ReadOnly == false)
        {
            sender.ReadOnly = true;
        }
    }

    Good Luck,
    Bart
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 16 Jan 2013 Link to this post

    Hi,

    You can check the readOnly from the visible element directly. Here is example JavaScript:

    function blurHandler(sender, args)
    {
        if ( ! sender.get_element().readOnly)
        {
            //do your logic
        }
    }

    Greetings,
    Vasil
    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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top