If you are willing to use jQuery and PHP, here's an exemple of what you can do:
HTML
<form action="Newsletter/tester.php" method="post">
<input type="email" name="email" id="email-input">
<button type="submit">Send</button>
<br/>
<span id="email-validate">Waiting for user input...</span>
</form>
jQuery
jQuery(function($) {
// When the user types something in the input
$('#email-input').on('keyup', function(e) {
// set the variables
var $input = $(this)
, value = $input.val()
, data = {
email: value
};
// perform an ajax call
$.ajax({
url: 'my/validator.php', // this is the target
method: 'get', // method
data: data, // pass the input value to server
success: function(r) { // if the http response code is 200
$('#email-validate').css('color', 'green').html(r);
$('button').removeAttr('disabled');
},
error: function(r) { // if the http response code is other than 200
$('#email-validate').css('color', 'red').html(r);
$('button').attr('disabled', 'disabled');
}
});
});
});
PHP (>= 5.4)
<?php
if(isset($_GET['email'])) {
$email = $_GET['email'];
if(filter_var($email, FILTER_VALIDATE_EMAIL)) {
http_response_code(200);
echo 'The email '.$email.' is valid';
} else {
http_response_code(412);
echo 'The email '.$email.' is not valid';
}
}