title: Stop HTML form from disappearing after AJAX call
body: <p>I am trying to make a comment system that has a basic validation in which the reply cannot be blank (0 characters).</p>
  
  <p>When a user hits the reply button, the system will respond with an AJAX call to display a form (Textarea). When the user submits the form and the textarea is empty, an error message will appear beneath the form. My problem is that the form disappears immediately after the user submits the form and does not allow me to display an error message.</p>
  
  <p>How do I stop the HTML form from disappearing until all validation succeeds?</p>
  
  <p>index.php:</p>
  
  <pre><code>&lt;script&gt;
    $(document).ready(function(){
      $(".replyText").click(function(){
        $.ajax({
          type: "GET",
          url: "reply_ajax.php",
          async: false,
          success: function(text){
          response = text;        
          }
        });
        $(this).after(response);
      });
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>reply_ajax.php:</p>
  
  <pre><code>&lt;div class="replydiv"&gt;
      &lt;textarea rows='4' cols='50' form='replyform' name='reply'&gt;
  
      &lt;/textarea&gt;
      &lt;form id='replyform' method='post'&gt;
              &lt;input type='submit' name='submit' class='submit'&gt;      
              &lt;input type='submit' name='cancel' value='Cancel'&gt;
      &lt;/form&gt; 
  &lt;/div&gt;   
  &lt;script&gt;
      $(function(){
              $(".submit").click(function(){
                      if($(this).closest('textarea').val() == "")
                              $(".comments").append("Please enter a reply!");                         
              });
      });
  
  &lt;/script&gt;
  </code></pre>