This is a migrated thread and some comments may be shown as answers.
RadInput for Asp.net - OnValueChanged
3 Answers 95 Views
This is a migrated thread and some comments may be shown as answers.
Lee Christensen
Top achievements
Rank 1
Lee Christensen asked on 06 May 2008, 01:42 PM
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.

3 Answers, 1 is accepted

Sort by
0
plamen
Top achievements
Rank 1
answered on 06 May 2008, 05:09 PM
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 />
0
Steele
Top achievements
Rank 1
answered on 19 Oct 2008, 05:26 AM
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
0
Lee Christensen
Top achievements
Rank 1
answered on 19 Oct 2008, 04:22 PM
You will find most of Telerik's javascript implementation is 'non-standard'.
Tags
Input
Asked by
Lee Christensen
Top achievements
Rank 1
Answers by
plamen
Top achievements
Rank 1
Steele
Top achievements
Rank 1
Lee Christensen
Top achievements
Rank 1
Share this question
or