title: Javascript verify user input
body: <p>I need major help, I've been on this code for two days now. I have this table produced by javascript, which is used to confirm user input. If the user sees an error, they can click on the cell and it enables the user to edit the content right there.  I'm trying to setup where it displays if the users email is valid, or invalid. The script works good, but if the user deletes the full email, the content is no longer editable, which would not be good. My code so far is:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;table id = 'confirm'&gt;
    &lt;tr&gt;
      &lt;th&gt;Email&lt;/th&gt;
      &lt;td id = 'tdEmail'&gt;
        &lt;div onkeyup = 'verifyEmail(this.parentNode.id)' contentEditable&gt;
          abc@123.com
          &lt;div id = 'validInvalid'&gt;
            &lt;span class = 'dgreen'&gt; //Use to create a sort of green for valid email, when the user first sees the confirm table, the email is valid.
              &lt;br/&gt;Valid email!
            &lt;/span&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;    
  </code></pre>
  
  <p>JS:</p>
  
  <pre><code>function verifyEmail(id){
    var email = document.getElementById.firstChild.firstChild.nodeValue;
    var emailFilter = /^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/;
    if(!emailFilter.test(email)){
      document.getElementById("validInvalid").innerHTML = "&lt;span class = 'red'&gt;&lt;br/&gt;Not a valid email!&lt;/span&gt;";
    }else{
      document.getElementById("validInvalid").innerHTML = "&lt;span class = 'dgreen'&gt;&lt;br/&gt;Valid email!&lt;/span&gt;";
    }
  }
  </code></pre>