title: Form Validation with jQuery before submitting via Ajax request
body: <p>I'm trying to get my form to validate before using an Ajax request to submit the form to my php script. I've looked through stackoverflow and haven't found something that worked.</p>
  
  <p>I have 3 inputs and a submit button:</p>
  
  <pre><code>&lt;input type="text" name="full-name" id="full-name" value="" placeholder="Full Name" /&gt;
  &lt;input type="text" name="email" id="email" value="" placeholder="Email" /&gt;
  &lt;textarea name="message" id="message" value="" rows="8" placeholder="Message"&gt;&lt;/textarea&gt;
  &lt;input type="submit" id="contact-submit" class="contact-submit" value="Submit"&gt;
  &lt;div id="messageResponse" class="center" style="display:none;"&gt;&lt;/div&gt;
  
  $(document).ready(function() {
  
      function validator(){
          return $('form').validate();
      }
  
      $('form').on('submit', function(e) {
          e.preventDefault();
  
          $.ajax({
              dataType: 'html',
              type: 'post',
              url: 'mail.php',
              data: $('#contact-form').serialize(),
              beforeSubmit: validator,
              success: function(responseData) {
                  $('#contact-submit').remove();
                  $('#messageResponse').fadeIn(1000);
                  $('#messageResponse').html(responseData);
              },
              error: function(responseData){
                  console.log('Ajax request not recieved!');
              }
          });
  
          // resets fields
          $('input#full-name').val("");
          $('input#email').val("");
          $('textarea#message').val("");
      })
  });
  </code></pre>
  
  <p>Should I use a plugin for this? All I want is the name, email, and message to validate with a red border-color. It's giving me a big headache and I'm meeting with the client tomorrow to finalize the site. I don't ask questions if I can't find a working solution.</p>
  
  <p>I tried using this as well: <a href="https://github.com/victorjonsson/jQuery-Form-Validator" rel="nofollow noreferrer">jQuery Form Validator Plugin</a></p>