2011-09-08 35 views
0

我必須建立一個自定義模塊,我已經在客戶註冊頁面添加了一個自定義字段,如備用郵件ID,移動編號&等成功保存在我的數據庫&這裏我必須實現一個更多的功能,是我如何限制其他域的用戶除了** abc.com **

當用戶輸入他的電子郵件ID,應該檢查域名註冊頁面。

例:我的域名是ABC &的用戶的郵件地址將是[email protected]

&的「abc.com」用戶只應該要得到註冊到我的網上商店 如何限制其他域的用戶除了abc.com

請幫我做這個.....

+0

[Magento的客戶的註冊](可能重複http://stackoverflow.com/questions/6936399/magento-customer - 註冊) – clockworkgeek

回答

0

您可以使用正則表達式來實現此目的。只要使用以下功能:

function checkEmail($email) { 
    if(preg_match("/^([a-zA-Z0-9\._-])*@abc.com$/",$email)){ 

    return true; 
    } 
    return false; 
} 

代碼編輯

<script type="text/javascript"> 
    function validateEmail(elementValue){ 
     var emailPattern = /^[a-zA-Z0-9._-][email protected]$/; 
     return emailPattern.test(elementValue); 
    } 

    function checkForm(){ 
     var emailId = document.getElementById('email_address').value; 
     if(! validateEmail(emailId)) { 
      alert("Email id is not valid"); 
     } 
    } 
</script> 

<div class="input-box"style="width: 550px;"> 
    <input type="text" name="email" id="email_address" value="<?php echo $this->htmlEscape($this->getFormData()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" /> 

    <input type="submit" value="Click here" onclick="checkForm()" />(There will be be an submit button put the onclick event in it) 

</div> 
+0

你能告訴我,我必須把這段代碼.... – Imran

+0

可以使用JavaScript完成相同的事情,如果是這樣,請給我一段代碼,它可以幫助我很多.... ... – Imran

+0

我已添加代碼。審查相同 – munjal

相關問題