title: show div when error is occur
body: <p>i have validated a form.i want to show error message in a div.it has red background.i want to show it only occur a error.but my code always shows the red background div.but error message shows when error occurs.i want to show red background div and message when only occur a error.</p>
  
  <p>html code</p>
  
  <pre><code>   &lt;form action="registerphp.php" method="post" id="regfrm" name="regfrm"&gt;&lt;br&gt;
  
     &lt;div class="form-group"  style="background-color: #FFBABA;color: #9F6000;border: 1px solid;margin: 10px 0px;padding:15px 10px 15px 50px;background-repeat: no-repeat;background-position: 10px center"&gt;
        &lt;span id="error_message" class="text-danger"&gt;&lt;/span&gt;
        &lt;span id="success_message" class="text-success"&gt;&lt;/span&gt;
     &lt;/div&gt;
     &lt;div class="form-group"&gt;
        &lt;label for="pwd"&gt;Title&lt;/label&gt;
        &lt;input type="text" class="form-control" id="title" name="title"&gt;
     &lt;/div&gt;
     &lt;div class="form-group"&gt;
          &lt;label&gt;Name&lt;/label&gt;
          &lt;input type="text"  class="form-control" id="name" name="name"&gt;
      &lt;/div&gt;
     &lt;div class="form-group"&gt;
          &lt;label&gt;phone&lt;/label&gt;
          &lt;input type="text"  class="form-control" id="phone" name="phone"&gt;
      &lt;/div&gt;
     &lt;/form&gt;
  </code></pre>
  
  <p>jquery code</p>
  
  <pre><code>   &lt;script type="text/javascript"&gt;
        $(document).ready(function () {
             $('#buttonregister').click(function () {
                   var title=$('#title').val();
                   var name=$('#name').val();
                   var phone=$('#phone').val();
  
                   if(title==""){
                       $('#error_message').html("Id is required");
                       alert('no');
                       return false;
                              }
                   if(name==""){
  
                        $('#error_message').html("Name is required");
                        alert('no2');
                        return false;
                           }
                       if(name==""){
  
                        $('#error_message').html("Name is required");
                        alert('no2');
                        return false;
                           }
                   });
              });
  </code></pre>