title: Displaying success and error messages using javascript
body: <p>Here is a simple javascript code for displaying error messages it works fine now how to add a statement to this code that states when none of these errors are committed display a success message.    </p>
  
  <p><code>JS</code></p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function() {
          $('#update').click(function() {
                  var firstname = document.getElementById('fname').value;
                  var lasttname = document.getElementById('lname').value;
                  if (firstname.length &lt; 2) {
                      $('#em').html('First name cannot be less than 2 characters');
                      return false;
                  }
                  if (lasttname.length &lt; 2) {
                      $('#em').html('Last name cannot be less than 2 characters');
                      return false;
                  }
                  if (firstname.length &gt; 15) {
                      $('#em').html('First name cannot be more than 15 characters');
                      return false;
                  }
                  if (lastname.length &gt; 15) {
                      $('#em').html('Last name cannot be more than 15 characters');
                      return false;
                  }
              }
          });
      });
  &lt;/script&gt;
  </code></pre>