I'm trying to implement email validation using the Bassistance jQuery plugin, with a check if the email adress exists.
The remote script returns correcctly true
or false
, however - no error message is shown. Other validation (required, email) works fine.
Any idea's what I'm missing here?
The jQuery code:
jQuery().ready(function() {
jQuery("#post").validate({
rules: {
lid_email: {
required: true,
email: true,
remote: {
type: 'POST',
url:"email-check.php"
}
}
},
messages: {
lid_email: {
required: 'Gelieve een geldig e-mailadres in te vullen.<br>',
email: 'Gelieve een geldig e-mailadres in te vullen.<br>',
remote: 'Dit adres bestaat reeds. Gelieve een ander adres te kiezen.'
}
}
})
jQuery('#lid_email').blur(function() {
jQuery("#post").validate().element( "#lid_email" );
});
});
And the remote script:
<?php
header('Content-type: application/json');
require('../../../wp-blog-header.php');
$request = trim(strtolower($_POST['lid_email']));
if ( email_exists($request) == TRUE ) {
echo json_encode(FALSE);
} else {
echo json_encode(TRUE);
}
?>