Magento - AJAX时事通讯验证数据库中已经存在的电子邮件

Magento - AJAX newsletter validate e-mails that already exist in the database

本文关键字:存在 电子邮件 数据库 验证 AJAX Magento      更新时间:2023-09-26

我使用这个ajax validation,但它不验证电子邮件是否已经存在于数据库中。如果您输入一个有效的电子邮件地址,它就会通过:

onSubmit="if(newsletterSubscriberFormDetail.validator.validate())
 {
   new Ajax.Updater({success:'newsletter-validate-detail'}, 'newsletter/subscriber/new', 
     { 
       asynchronous:true, evalScripts:false, onComplete:function(request, json) 
     {
       Element.hide('newsletter-validate-detail');Element.show('pop-confirm');
     },  
       onLoading:function(request, json){}, parameters:Form.serialize(this)
     }); 
 } return false;"

我试着修改onsubmit函数,但无济于事。我希望这里有人可以教我如何使这个验证工作,以便它将检查输入的电子邮件是否已经存在。

这是标准的Magento行为。它不会检查电子邮件是否已经存在,并且总是显示"感谢您的订阅"。

你可以检查Mage_Newsletter_SubscriberControllernewAction,它只检查现有的电子邮件,如果你登录并试图输入别人的电子邮件地址:

if ($ownerId !== null && $ownerId != $customerSession->getId()) {
    Mage::throwException($this->__('This email address is already assigned to another user.'));
}

你可能需要重写这个方法来实现'Email已经存在'错误。