RadInput for Asp.net - OnValueChanged

4 posts, 0 answers
  1. Lee Christensen
    Lee Christensen avatar
    2 posts
    Member since:
    May 2007

    Posted 06 May 2008 Link to this post

    After upgrading to RadControls for ASP.NET ( not ASP.NET AJAX ) my client-side validation does not perform properly.  The code below puts the function into an infinite loop.

    function ValidateLongitude(sender, args)
    {
        var newValue = String(args.NewValue);
        if( newValue.charAt(0) != '-' )
        {
            newValue = '-' + newValue;
            sender.SetValue(newValue);
        }

        if( newValue.length >= 4 && newValue.indexOf('.') < 0 )
        {
            if( newValue.substring(0,4) < -520 )
            {
                newValue = newValue.substring(0,3) + '.' + newValue.substring(3);
            }else{
                newValue = newValue.substring(0,4) + '.' + newValue.substring(4);
            }
            sender.SetValue(newValue);
        }   
       
        if( newValue != '' && (newValue > -52 || newValue < -142 ))
        {
            sender.SetValue('');
        }
    }

    Given the code below does not cause an infinite loop, can you explain why Telerik is calling the OnValueChanged every time we try to set the text box to a new value?
    <html>
    <head>
    <script>
    function BlurIt()
    {
    var x = document.getElementById("txtID");
    x.value = "new value";
    }
    </script>
    </head>
    <body>
    <form>
    <input type="text" id="txtID" onblur="BlurIt();">
    </form>
    </body>
    </html>

    And upgrading to Asp.net AJAX is not option.

  2. John
    John avatar
    416 posts
    Member since:
    Oct 2006

    Posted 06 May 2008 Link to this post

    Lee,

    You can use OnBlur event instead of OnValueChanged

    The OnBlur client-side event handler is called when the input control loses focus.


    Thanks...
    <John:Peel />
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Steele
    Steele avatar
    58 posts
    Member since:
    Jun 2006

    Posted 19 Oct 2008 Link to this post

    I have this same problem in 2008 Q2 SP2...

    In my case I cannot use onblur because I am firing a server load based on the value and I don't want it to fire evertime I exit the textbox if the value doesn't change.

    See the description and code here:
        http://www.telerik.com/community/forums/thread/b311D-bdagge.aspx

    Please advise on how to suppress this behavior since it is NON-Standard javascript behavior, an Html Input control does not fire onchaged when setting the value from javascript, only when setting the value from the keyboard.

    Thanks,

    Steele Price
  5. Lee Christensen
    Lee Christensen avatar
    2 posts
    Member since:
    May 2007

    Posted 19 Oct 2008 Link to this post

    You will find most of Telerik's javascript implementation is 'non-standard'.
Back to Top