title: JS - getElementById not working. Firefox throws: Syntax Error Chrome throws: Unexpected }
body: <p>Validating a form is not working. Below you see the code and error message.
  Don't think its a problem with JS, Chrome and Firefox point to the HTML part.
  See screenshot I made from Firefox' Firebug.</p>
  
  <p><img src="https://i.stack.imgur.com/qx5rN.png" alt="enter image description here"></p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div&gt;Enter your state code:&lt;input id="state" name="state" type="text" size="2" onblur="isStateOk(this.document.getElementById("state_help"));"/&gt;        
  &lt;span id="state_help"&gt;&lt;/span&gt;&lt;/div&gt; 
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>function isStateOk(inputField, helpId) {        // See if the input value contains any text
  
      return editNodeText (/^A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY]$/, inputField.value, helpId, "Enter a State Code in Uppercase (Ex.NY, PA, CA)");
  }
  </code></pre>
  
  <p>Note: <code>eclipse</code> show a red dotted line under: ("<code>state_help</code>"). Maybe the <code>id</code> of the <code>span</code> cannot be found at all? I do get code assistance though when start typing <code>state_</code></p>
  
  <p>UPDATE: JAVASCRIPT FILE: NEW ERROR MESSAGE POINTING TO THE FIRST FUNCTION IN THIS FILE BELOW:</p>
  
  <pre><code>function editNodeText(regex, input, helpId, helpMessage) {        // See if the visitor entered the right information
  
      if (!regex.test(input)) {          // If the wrong information was entered, warn them
  
          if (helpId != null)
  
              while (helpId.firstChild) // Remove any warnings that may exist
  
                  helpId.removeChild(helpId.firstChild);
  
                  helpId.appendChild(document.createTextNode(helpMessage)); // Add new warning
  
                  return false;
      } else {          // If the right information was entered, clear the help message
  
          if (helpId != null){
  
              while (helpId.firstChild) // Remove any warnings that may exist
  
                  helpId.removeChild(helpId.firstChild);
          }
  
          return true;
  
      }   
  }
  
  
  
  
  //inputField – ID Number for the html text box
  //helpId – ID Number for the child node I want to print a warning in
  //See if the input value contains any text
  function isTheFieldEmpty(inputField, helpId) {          
  
      return editNodeText(/^[A-Za-z\.\' \-]{2,15}\s?[A-Za-z\.\' \-]{2,15}\s?[A-Za-z\.\' \-]{2,15}/, inputField.value, helpId, "Please enter a valid name.");
  } // inputField.value – Value typed in the html text box
  
  
  
  function isAddressOk(inputField, helpId) {        // See if the input value contains any text
  
      return editNodeText(/^[A-Za-z0-9\.\' \-]{5,30}$/, inputField.value, helpId, "Enter a Street (Ex.1234 Main St.)");
  }
  
  
  
  function isStateOk(inputField, helpId) {        // See if the input value contains any text
  
      return editNodeText (/^A[LKSZRAEP]|C[AOT]|D[EC]|F[LM]|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEHINOPST]|N[CDEHJMVY]|O[HKR]|P[ARW]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY]$/, inputField.value, helpId, "Enter a State Code in Uppercase (Ex.NY, PA, CA)");
  }
  
  
  
  function isPhoneOk(inputField, helpId) {        // See if the input value contains any text
  
      return editNodeText(/^([0-9]( |-)?)?(\(?[0-9]{3}\)?|[0-9]{3})( |-)?([0-9]{3}( |-)?[0-9]{4}|[a-zA-Z0-9]{7})$/, inputField.value, helpId, "Enter a Phone Number (Ex.412-828-3000)");
  }
  
  
  
  function isEmailOk(inputField, helpId) {        // See if the input value contains any text
  
      return editNodeText(/^[A-Za-z0-9._-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/, inputField.value, helpId, "Enter an Email (Ex. cimdata@javascript.de)");
  
  }
  </code></pre>