我正在使用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