[jQuery] IE val() raises blur event

[jQuery] IE val() raises blur event


Hi,
I'm getting a frustrating problem in IE (as usual). In a textbox's
onblur event, I'd like to check if the user has entered something and
change the value. I setup the onblur event:
    .blur(function() {
        // track whether the field has focus
        alert('blur called');
        if(this.value.length == 0){selectItem(null)};
        hasFocus = false;
        hideResults();
    });
and the selectItem function
function selectItem(li) {
if(li.extra.sFirstName)
{
alert('setting name');
$("#txtSearch").val(li.extra.sFirstName + ' ' +
li.extra.sLastName);
$("#txtPerson").val(li.extra.ixPerson);
}
else if(fLoaded)
{
alert('checking blank');
if( $("#txtSearch").val().length > 0 )
{
alert('setting blank');
}
}
else
fLoaded = true; // get around IE's setTimeout(onItemSelect())
misordering
}
But I'm finding that in IE 6 this causes an infinite loop. After
alerting 'checking blank' the
$("#txtSearch").val().length
is raising the onblur() event, which calls SelectItem, and there is
the loop. Is this a known problem? Is there a way to get the value
of the text input without raising the onblur event?