How to check in an entered value is from autocomplete?
<p>I have a jquery's autocomplete texbox and, upon a click of a button, I need to check if the value entered has come from the autocomplete or is it a completely new value.</p>

<p>The problems is that my code constantly gives me 'alert("no")'... maybe I shouldn't be checking against 'cache', but something else?</p>

<pre><code>//////////////////////////////////////////// autocomplete code //////////////////
        var cache = {},
            lastXhr;
        $( "#inputV" ).autocomplete({
            minLength: 2,
            source: function( request, response ) {
                var term = request.term;
                if ( term in cache ) {
                    response( cache[ term ] );
                    return;
                }

                lastXhr = $.getJSON( "search.php", request, function( data, status, xhr ) {
                    cache[ term ] = data;
                    if ( xhr === lastXhr ) {
                        response( data );
                    }
                });
            }
        });


////////////////////////// check if input comes from autocomplete  //////////////////
        $('#btn_check').click(function()        {

            var input = $("#inputV").val();
            alert(input);

            if ( input in cache ) 
                {
                    alert("yes");
                 }  
                else
                {
                    alert("no");
                }   
        });
</code></pre>

<p><img src="http://i.stack.imgur.com/Z5eYF.jpg" alt="enter image description here"></p>
