I'm using JSN Uniform plugin for Joomla to receive emails, but it's not accepting the .company domain as a valid domain. It accepts the usual domains (com, net, org, info, biz,...), but domains like .company aren't accepted.
Now, I'm really not experienced in PHP, as I'm more into JavaScript, but according to my poor knowledge the solution to my problem could be in the form.php file so here is the part of a code.
PHP:
private function _fieldEmail($post, $fieldIdentifier, $fieldTitle, &$validationForm)
{
$postFieldIdentifier = isset($post[$fieldIdentifier]) ? $post[$fieldIdentifier] : '';
$postFieldIdentifier = (get_magic_quotes_gpc() == true || get_magic_quotes_runtime() == true) ? stripslashes($postFieldIdentifier) : $postFieldIdentifier;
$postEmail = $postFieldIdentifier;
if ($postEmail)
{
$regex = '/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,6})$/';
if (!preg_match($regex, $postEmail))
{
$validationForm[$fieldIdentifier] = JText::sprintf('JSN_UNIFORM_FIELD_EMAIL', $fieldTitle);
}
else
{
return $postFieldIdentifier ? $postFieldIdentifier : "";
}
}
else
{
return $postFieldIdentifier ? $postFieldIdentifier : "";
}
}
Could someone help me please with this?
Thanks.
EDIT: I have tried to change regex value from 2,6 to 2, but still no change.
Please see php fiddler here: http://viper-7.com/CqxAMZ
Change {2,6}
to {2,7}
at the end.
That indicates the last part of the regex should contain between 2 and 7 characters ("company" exceeds the limit of 6).
You should replace the regex like this:
$regex = '/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,})$/';
to accept a domain of any size bigger than one. Now it is restricted to sizes between 2 and 6. More on the subject in http://www.regular-expressions.info/repeat.html
Replace:
$regex = '/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,6})$/';
if (!preg_match($regex, $postEmail))
{
$validationForm[$fieldIdentifier] = JText::sprintf('JSN_UNIFORM_FIELD_EMAIL', $fieldTitle);
}
with:
if (!filter_var($postEmail, FILTER_VALIDATE_EMAIL)) {
$validationForm[$fieldIdentifier] = JText::sprintf('JSN_UNIFORM_FIELD_EMAIL', $fieldTitle);
}
Email validate is more complicated that a one-line regex.