autocomplete get reuslt

autocomplete get reuslt

hello guys.

i'd like to get the result of my autocomplete.
now i have this code:

$("#keresett").autocomplete(data, {
    formatItem: function(item) {
    return item.text;
}
}).result(function(event, item) {
    $("#t_id").val(item.url);
}
});
$("#btn_kereses").click(function() {
    var id = $("#t_id").val();
});

Ok. My problem is, if the user type something, what is not in the local list (data is from local), then the #t_id.val wont change, even if i try do insert an if like this:

}).result(function(event, item) {
    if (!item) {
        $("#t_id").val(item.url);
    } else {    
        $("#t_id").val(item.url);
    }
}

So how can i get the actual value of the result (0 if none) with this:
$("#btn_kereses").click(function() {

Please do not reply a "check result handler" because i did read that, but as you see, i do not understand that.