 <p>if you are fine adding variables to the global scope then:</p> <pre><code>var firstname; var secondname; var checkName = function() { if(firstname != null &amp;&amp; secondname != null){ console.log(firstname); console.log(secondname); } } $('#first_name').live("change", function(){ firstname=$(this).val(); checkName(); }); $('#second_name').live("change", function(){ secondname=$(this).val(); checkName(); }); </code></pre>