How to change bordercolor based on value of textbox? using javascript
<p>I have a textbox which has a red border as default.</p>

<p>when on focus, (:focus) the border turns green.</p>

<p>When there is 1 or more characters in the textbox, the border turns blue (using this js)</p>

<pre><code>function CheckText()

{

    var elem = document.getElementById('sendto');

    if(elem)

      {      
      if(elem.value.length != 0)
      elem.style.borderColor = '#3366CC';
      }

}
</code></pre>

<p>the problem I have is, if I delete all the characters from the box after it has turned blue, it stays blue and does not return to red. the :focus green does not work anymore either after typing in the cell.</p>

<p>Can anyone help?</p>

<p>this is the HTML code for my box:</p>

<pre><code>&lt;input id="sendto" name="sendto" type="text" class="sendsubempty" onBlur="CheckText()" value="&lt;? 
  if(!$sendto){ 
  echo"";
  }else{
  echo"$sendto";
  }
  ?&gt;" maxlength="50" /&gt;
</code></pre>

<p>for info: class- sendsubempty has a red border.</p>

<p>I have seperate classes for blue &amp; green borders if its easier to use in the javascript.</p>

<p>Please help :(</p>
