title: JavaScript validation for empty input field
body: <p>I have this input field 
  <code>&lt;input name="question"/&gt;</code> I want to call IsEmpty function when submit clicking submit button.</p>
  
  <p>I tried the code below but did not work.
  any advice?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  
  &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=unicode" /&gt;
    &lt;meta content="CoffeeCup HTML Editor (www.coffeecup.com)" name="generator" /&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
  
    &lt;script language="Javascript"&gt;
      function IsEmpty() {
  
        if (document.form.question.value == "") {
          alert("empty");
        }
        return;
      }
    &lt;/script&gt;
    Question: &lt;input name="question" /&gt; &lt;br/&gt;
  
    &lt;input id="insert" onclick="IsEmpty();" type="submit" value="Add Question" /&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>