i got the plugin and its working as expected ,except now all i want is to disable the submit button if the email was invalid & re-enable it again if the email became valid ,so how to do that ?
JS
$('#email').mailgun_validator({
api_key: 'xxxx',
in_progress: validation_in_progress,
success: validation_success,
error: validation_error,
});
// in_progress
function validation_in_progress() {
$('#status').html("<img src='assets/loading.gif' height='16'/>");
}
// success
function validation_success(data) {
$('#status').html(get_suggestion_str(data['is_valid'], data['did_you_mean']));
}
// invalid
function validation_error(error_message) {
$('#status').html(error_message);
}
// suggest a valid email
function get_suggestion_str(is_valid, alternate) {
if (alternate) {
return '<small class="help-block warning">Did you mean <b>' + alternate + '</b>?</small>';
} else if (is_valid) {
return '';
} else {
return '<small class="help-block error">Address is invalid.</small>';
}
}
and the code for the submit btn
$("#validate_submit").attr('disabled');
but i don't know where i should add it to the js above.