title: Validate form data
body: <p>I have a form that that is already validated by jquery.validate.min.js, what I want is another validation method, ajax call to mysql to check if the email address is already in my DB. How do I merge the validations? I already played a little with the codes but can't figure it out.</p>
  
  <p>My form: <a href="http://demos.creative-tim.com/wizard-demo-register?_ga=2.138099576.979789193.1518540669-1813170823.1518540669" rel="nofollow noreferrer">http://demos.creative-tim.com/wizard-demo-register?_ga=2.138099576.979789193.1518540669-1813170823.1518540669</a></p>
  
  <p>My validation code:</p>
  
  <pre><code>$('document').ready(function() {
    var email_state = false;
    $('#email').on('blur', function() {
      var email = $('#email').val();
      if (email == '') {
        email_state = false;
        return;
      }
      $.ajax({
        url: 'index.php',
        type: 'post',
        data: {
          'email_check': 1,
          'email': email,
        },
        success: function(response) {
          if (response == 'taken') {
            email_state = false;
            alert('email is taken');
          } else if (response == 'not_taken') {
            email_state = true;
            alert('email available');
          }
        }
      });
    });
  });
  </code></pre>
  
  <p>The PHP who process the email check:</p>
  
  <pre><code>        &lt;?php
        $db = mysqli_connect('localhost', 'user', 'pass', 'subscribers');
        if (isset($_POST['email_check'])) {
          $email = $_POST['email'];
          $sql = "SELECT * FROM subscribers WHERE email='$email'";
          $results = mysqli_query($db, $sql);
          if (mysqli_num_rows($results) &gt; 0) {
            echo "taken";
          }else{
            echo 'not_taken';
          }
          exit();
        }
        ?&gt;
  </code></pre>