title: jquery empty string field exception handling
body: <p>In the beginning I use alert but felt it's not that nice.. It add extra step to the user and quite annoying.. </p>
  
  <p>I want to do like if field is empty then restore the previous value.</p>
  
  <pre><code>&lt;ul id="task-group"&gt;
                  &lt;li class="active"&gt;&lt;a href="#"&gt;Personal&lt;/a&gt;&lt;/li&gt;
                                      &lt;li class="active"&gt;&lt;a href="#"&gt;Work&lt;/a&gt;&lt;/li&gt;
  
              &lt;/ul&gt;   
  
  
                  &lt;input type="text" name="task-group" style="display:none"&gt;
  </code></pre>
  
  <p>jquery:</p>
  
  <pre><code>$(document).ready(function () {
  
  var addInput = $('input[name="task-group"]').hide();
  var beforeItems = $('li.active');
  
  beforeItems.on('dblclick', itemClick);
  
  function inputKeydown(e) {
      var $this = $(e.target).closest('input[type="text"]');
  
      if (e.keyCode == 13) {
          $this.blur();
      }
  }
  
  function itemClick(e) {
      var $this = $(e.target).closest('li.active');
      var txt = $this.find('a').text();
  
      var input = $("&lt;input type='text'/&gt;").val(txt);
      $this.html('');
  
      input.appendTo($this).focus();
      input.on('blur', editInputBlur);
      input.keydown(inputKeydown);
  }
  
  
  function editInputBlur(e) {
      var $this = $(e.target).closest('input[type="text"]');
      var v = $this.val();
  
      if (v.trim() == "") {
  
      } else {
          var $a = $("&lt;a href='#'&gt;" + v + "&lt;/a&gt;");
          $this.parent().append($a);
          $this.remove();
      }
  }
  
  
  });
  </code></pre>
  
  <p>but I always got empty html field with val() method, help.. (line 34)</p>
  
  <p><a href="http://jsfiddle.net/VE7Tq/1/" rel="nofollow">http://jsfiddle.net/VE7Tq/1/</a></p>