title: Cannot read property length of undefined
body: <p>I am trying to simply check if I have an empty input text box but I get this error when I run this in Chrome:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'length' of undefined.</p>
  </blockquote>
  
  <p>Here is how I go about doing it.  I check for DOM readiness and then call the function:</p>
  
  <pre><code>function walkmydog() {
      //when the user starts entering                                                                                                                                                
      if(document.getElementById('WallSearch').value.length == 0) {
          alert("nothing");
      }
  }
  
  if (document.addEventListener) {
      document.addEventListener("DOMContentLoaded", walkmydog, false);
  }
  </code></pre>