title: Validate fields before updating
body: <p>I am stuck on attempting to validate my form data before I am able to perform and AJAX update. So basically what I am trying to achieve is validate the form input data before the ajax update function. I do not know where I would place the functions for validation inside the method below:
  My AJAX updating function:</p>
  
  <pre><code>$("#updateUser").click(function() {
              $.ajax({
                  type: "POST",
                  url: "${pageContext.request.contextPath}/updateUser",
                  data: $("#updateForm").serialize(),
                  success: function(response) {
                      $("#alert").show();
                  },
                  error: function(XMLHttpRequest, textStatus, errorThrown) { 
                      alert("Status: " + textStatus); alert("Error: " + errorThrown); 
                  } 
              });
          });
  </code></pre>
  
  <p>This is the form I am attempting to validate:</p>
  
  <pre><code>    &lt;form id="updateForm"&gt;
                      &lt;input type="hidden" id="id" name="id" /&gt; 
                      Name:
                      &lt;input type="text" name="name" id="name" /&gt;
                      &lt;br /&gt; 
                      User name:
                      &lt;input type="text" name="username" id="username" /&gt;
                      &lt;br /&gt; 
                      Email:
                      &lt;input type="text" name="email" id="email" /&gt;
                      &lt;br /&gt; 
                      Authority
                      &lt;input type="text" name="authority" id="authority" /&gt;
                      &lt;br /&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>Any suggestions please help, I am new to javascript. Thanks</p>