title: Change background color of input text field using JavaScript
body: <p>How do I change the background color of a input text field using java script? I want to insert it in a form validation function like this:</p>
  
  <pre><code>        function validateForm()
          {
          var x=document.forms["form1"]["username"].value;
          if (x==null || x=="")
            {
     document.forms["form1"]["username"].style.backgroundColor = Black
            }
          }
  </code></pre>
  
  <p>Also, is there a way to do form validation with php without creating two pages? WHat would you recommend? Using JavaScript or php for validating the user input of a form? I already have a php process form which checks whether the user supplied the correct details like the password etc. </p>
  
  <p>Thank you for any help</p>