The Login button should only be enabled when the user enters a valid e-mail address into the Username field. Currently e-mail validation is handled through a PHP script. Any suggestions, alternatives or documentation to look into would be great.
index.html
<!DOCTYPE html>
<html>
<head>    
</head>
<body>
  <div id="login-input">
    <form action="login.php" method="post" class="ajax">
      <p>
        <input id="login-username" type="text" name="username" placeholder="Username">
      </p>
      <p>
        <input id ="login-password" type="password" name="password" placeholder="Password">
      </p>
      <p>
        <input id="login-submit-btn" type="submit" value="LOGIN" disabled>
      </p>
    </form>
  </div>
</body>
</html>
main.js
  $(document).ready(function() {    
  $('form.ajax').submit(function(event) {
    var data = {
      username: $('#login-username').val(),
      password: $('#login-password').val()
    };
    $.ajax({
      url: "login.php",
      type: "POST",
      data: data,
      success: function(data) {
        event.preventDefault();
        console.log(data);
      }
    });
    return false;
  });
});
login.php
  <?php
  $input_username = $_POST['username'];
  $input_password = $_POST['password'];
  if(isset($input_username, $input_password)) {
    if(filter_var($input_username, FILTER_VALIDATE_EMAIL)) {
      echo " email format is valid ";
    }
    else {
      echo " email format is invalid ";
    }
  }
?>
 
     
    