score:0

Accepted answer

Not sure if this was the best solution, but it works as it should do.

<input id="submit" type="submit" value="Submit">

if email found:

echo '<script> $(document).ready(function() { $("#submit").attr("disabled", "disabled"); }); </script>';

if email not found:

echo '<script> $(document).ready(function() { $("#submit").removeAttr("disabled"); }); </script>'; 

It works :-)

score:0

You can work whitout submit button perfectly, with a button type="button" . I think you are looking for something like this:

function check_email_ajax(e_mail){
        $("#email-result").html('<img src="../cms/assets/images/loading.gif" width="20px" height="20px" />');
        $.post('ajax/register.ajax.php', {'email':e_mail}, function(data) {
          $("#email-result").html(data);
          var result= $("i").attr("id")
          if (result==red){
             //If this is the result you stay on the page and user see the red message :)
          }
          if (result==green){
            //If result is green I imagine you want to go where the action in form tag says, so delete action from the form, you can simply redirect where you want:
            url = "your-file.php"
            $(location).attr("href", url)
          }
        });
    }

Add a id for icons:

if($statement->fetch()){
    die('<i class="fa fa-times-circle" id="red" style="color:red;" aria-hidden="true"></i> <small>(taken)</small>');
}else{
    die('<i class="fa fa-check" id ="green" style="color:green;" aria-hidden="true"></i> <small>(Yeey :-) )</small>');
}}

Hope it helps you.


Related Query

More Query from same tag