title: Simple validation using JQuery Not Working
body: <p>I am trying to make a label's text green in color whenever I enter a value in the text box. If not then label's text color will be blue. </p>
  
  <p>When I enter a value into the text box that time the label's color is changing to green. However, when I delete the text, the label stays green and does not change to blue.</p>
  
  <p>My HTML code is:    </p>
  
  <pre><code>&lt;html&gt;&lt;body&gt;&lt;form&gt;  
      &lt;input type="text" id="name" name="name" placeholder="First Name" /&gt;
      &lt;label for="name"&gt;First Name &lt;/label&gt;  
  &lt;/form&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>My script is:</p>
  
  <pre><code>&lt;script type="text/javascript" src="jquery-1.5.2.min.js"&gt;&lt;/script&gt;   
  &lt;script type="text/javascript"&gt;  
      $(document).ready(function(){  
          $('input[type="text"]').focusin(function() {  
              var sd=$(this).attr('id');  
              var val=$(this).val();  
              $('label[for^="'+sd+'"]').css('display','inline');  
          });  
  
          $('input[type="text"]').focusout(function() {  
              var val=$(this).val();  
              var sd=$(this).attr('id');               
              if(val===''){  
                  $('label[for^="'+sd+'"]').css('display','none');  
              }  else {
                  $('label[for^="'+sd+'"]').css({
                      'display':'inline',
                      'color':'#82A714'
                  });
              }    
           });  
      });  
  &lt;/script&gt;
  </code></pre>