title: How to convert a simple jquery to jquery function
body: <p>I have the following code-</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function() {
          $("#clanname").keyup(function(e) {
  
              var clanname = $(this).val();
              if (clanname.length &lt; 4) {
                  $("#user-result").html('');
                  return;
              }
          if (clanname.length &gt;= 4) {
              $("#user-result").html('&lt;img src="images/ajax-loader.gif" /&gt;');
              $.get('getClanName', {clanname:clanname}, function(data) {   
  
                      if(data=='free')
                      {
                      $("#user-result").html('&lt;img src="images/available.png" /&gt;');
  
                  }else{
                      $("#user-result").html('&lt;img src="images/not-available.png" /&gt;');
                  }
                  });
              }
          });
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>which I put in the head section of my php file, but I want to put this in a seperate .js file and want to call this code on the text changed event of my textbox.and I want to make it parameterized function and want to pass the textbox's text to that function Can somene please suggest me how to to this.</p>