title: Detect if text field is empty or not and trigger code once, unless the state changes
body: <p>I want to detect if this text field is empty or not and then run some code based on that.</p>
  
  <p><strong>Question is:</strong> how can I run the code only once ...and then run it once again each and every time  that the state of the text field changes during one <code>focus</code> </p>
  
  <ul>
  <li>Different states being <code>empty</code> or <code>not empty</code>.</li>
  </ul>
  
  <hr>
  
  <p><strong>To further elaborate:</strong></p>
  
  <p>( The most important part in these jsfiddle's are shown in the console. )</p>
  
  <ul>
  <li><p><a href="http://jsfiddle.net/lollero/LncWS/" rel="nofollow">Here is a jsfiddle of a code</a> that executes the code every
  time you keyup (Not what I want. Just the initial code. ).</p>
  
  <pre><code>$('input').on("keyup", function() {
  
      var val = $(this).attr('value'),
          previous = $(this).prev();
  
      if ( val === '' ) {
          console.log('Empty');
      }
      else if ( val !== '' ) {
          console.log('Text');
      }
  
  });
  </code></pre></li>
  <li><p>and <a href="http://jsfiddle.net/lollero/LncWS/1/" rel="nofollow">Here is a jsfiddle of a code</a> that executes the code once 
  per focus (This is somewhat near to what I want). </p>
  
  <p><strong>What it is still missing, and what I can't seem to get done, is to basically run the code once again each and every time that the state
  changes during that one focus.</strong> How could I do that?</p>
  
  <pre><code>$('input').on("focus", function() {
  
      $('input').one("keyup", function() {
  
          var val = $(this).attr('value'),
              previous = $(this).prev();
  
          if ( val === '' ) {
              console.log('Empty');
          }
          else if ( val !== '' ) {
              console.log('Text');
          }
  
      });
  
  });
  </code></pre></li>
  </ul>