title: How change border color of text box when text box empty Lost focus event and onfocus event if text not empty then dont change border color
body: <p>I want to change text box's border color if text box is empty, using events.</p>
  
  <p><strong>js</strong></p>
  
  <pre><code>$(document).ready(function () {
      $("#name1").onFocus(function () {
          if ($("#name1").val() == "") $(this).css({
              "border": "red",
          });
          $("#name1").LostFocus(function () {
              if ($("#name1").val() != "") $(this).css({
                  "border": "",
              });
          });
      });
  });
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;form action=""&gt;
      &lt;input id="name1" type="textbox"&gt;&lt;/input&gt;
      &lt;input id="name2" type="textbox"&gt;&lt;/input&gt;
      &lt;input id="name3" type="textbox"&gt;&lt;/input&gt;
      &lt;input type="button" value="submit"&gt;&lt;/input&gt;
  &lt;/form&gt;
  </code></pre>