title: How to trigger an event when the user clears the text field and focus out of the text field using Jquery?
body: <p>I need to write an event handler when user clears the text field and moves out of focus from the same.</p>
  
  <p>I'm using the following function to catch "focus out" event.</p>
  
  <pre><code>$("input[type=text]").blur(function () {
  }
  </code></pre>
  
  <p>I have the followingfunction to capture clear field event.</p>
  
  <pre><code>$("input[type=text]").keyup(function() {
              if (!this.value) {
       }
  }
  </code></pre>
  
  <p>I tried using the keyup() function inside blur() since I need to capture the focus out and then clear field. This is how my code looks like:</p>
  
  <pre><code>$("input[type=text]").blur(function () {
  $(this).keyup(function() {
              if (!this.value) {
              }
        }
  }
  </code></pre>
  
  <p>But it doesn't work. Clear field event is triggered even before focus is out of the field. Also, it is triggering the event multiple times. What is the problem here?</p>