我正在使用Joomla的JSN Uniform插件接收电子邮件,但它不接受.company域作为有效域。它接受通常的域名(com,net,org,info,biz,...),但不接受像.company这样的域名。域名公司未被接受
现在,我真的没有在PHP方面有经验,因为我更喜欢JavaScript,但根据我的知识,我的问题的解决方案可能在form.php文件中,所以这里是代码的一部分。
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 : "";
}
}
有人能帮助我,请与本?
谢谢。
编辑:我试图将正则表达式值从2,6改为2,但仍然没有改变。
请参阅PHP的小提琴手在这里:http://viper-7.com/CqxAMZ
谚语的好例子*如果用正则表达式解决问题,现在有两个问题。* :-)认真地告诉“JSN Uniform”插件开发人员要与时俱进。 –
@OllieJones人们在电子邮件验证方面对正则表达式抱怨很多,但最深入和最自信的表达方式在那里;涵盖99.99%的“真人”甚至不会介绍的边缘案例:P – Flosculus
我编辑了这个问题。 – super11