title: JavaScript after Form Handling spit content on page
body: <p>Hello I'm trying to make a website where you enter your name and it gets spit out on the page. I want to do this using JavaScript.</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>    &lt;div id='errormsg'&gt;&lt;/div&gt;
      &lt;form action='' method='post' onsubmit="formSubmit();"&gt;
          &lt;input id='name' type='text' placeholder='Slogan here...'&gt;
          &lt;input id='submit' type='submit' value='Generate'&gt;
      &lt;/form&gt;
      &lt;div id="nameContent"&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>function formSubmit() {
  var formName, formError, nameSentence;
  formError = document.getElementById("errormsg");
  formName = document.getElementById("name");
  nameSentence = document.getElementById("nameContent");
  if (formName == "") {
      formError.innerHTML = "Put your name in!";
  } else if (formName &gt; 20) {
      formName.innerHTML = "Max. 20 characters";
  } else {
      nameSentence.innerHTML = formName ;
      }
  }
  </code></pre>
  
  <p>The first problem is that it doesn't give me any result. I'm in the learning process of JavaScript so please tell me what is wrong. The divs <code>errormsg</code> and <code>nameContent</code> are on the page. So that is not the problem.
  <strong>I want this to happen without jQuery just plain JavaScript</strong></p>