Hi,
".om" is actually a valid syntax but not valid in terms of semantics.
If you want it sort of bulletproof you need to create a validation that checks checks if the mailserver actually exists (MX DNS lookup) or create an ever-changing full list of TLDs.
We left that out because the latter can never complete and the first is not always working for every host (some hosting providers don't allow the use of PHP's checkdnsrr()):
- In you email field's validation, choose "custom"
- Copy the code below into the codebox and change FIELDNAME with the name (not title) of your email field:
function ff_FIELDNAME_validation(element, message)
{
let valid_email = ff_validemail( element, message );
let valid_mx = true;
JQuery.ajax({ //starts the ajax request
type: "POST", //define method "GET" or "POST"
url: '<?php return JURI::getInstance()->toString() ?>', //the PHP file to call for DB queries or other processing
data: {check_email: element.value}, //values to pass to the PHP file
async: false, // we need it instantly
success: function(data){//success callback function starts here
console.log(data);
valid_mx = data.valid_mx;
}
}); //ajax
if (valid_email != '' || !valid_mx) {
if (message=='') message = element.name+" faild in my test.\n"
ff_validationFocus(element.name);
return message;
} // if
return '';
}
- In form advanced => more options => form pieces => before form => click "custom"
- add the code below into the codebox:
if( JRequest::getVar('check_email', '') != '' ){
if (ob_get_level()) ob_end_clean();
while (ob_get_level()){
ob_end_clean();
}
$result = new stdClass();
$array = explode("@",JRequest::getVar('check_email', ''));
$domain = array_pop($array);
if(checkdnsrr($domain,"MX")){
$result->valid_mx = true;
} else {
$result->valid_mx = false;
}
header('Content-Type: application/json');
echo json_encode($result);
exit;
}
Save and close and try the email validation.
As reference, I also attached you a working form to this reply.
To try it out, please download, unzip and import it in BF => Configuration => Package Installer.
Regards,
Markus