title: javascript Uncaught TypeError: Cannot read property 'firstChild' of null
body: <p>I am getting the following error in Google Chrome on a very old Form I inherited (seems to work OK in IE, no errors)</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'firstChild' of null</p>
  </blockquote>
  
  <p>The error applies to the following js <strong>elem.firstChild.nodeValue = dispmessage;</strong>:</p>
  
  <pre><code>function msg(fld,     
           msgtype, 
           message) {
    if (emptyString.test(message))
      dispmessage = String.fromCharCode(nbsp);
    else
      dispmessage = message;
  
    var elem = document.getElementById(fld);
    elem.firstChild.nodeValue = dispmessage;
  
    elem.className = msgtype;   // set the CSS class to adjust appearance of message
  };
  </code></pre>
  
  <p>Wondering if someone has come across similar issue before? Any ideas on how I can resolve?</p>
  
  <p>Cheers</p>