Saturday, October 1

How to Add Confirmation email field while Register in Magento

The following method allows you to add confirmation email address field in your customer registration or newsletter page.
Create a javascript file called validation.js under "js/email/validation.js"

Validation.addAllThese([

    ['validate-cemail', 'Please make sure your emails match.', function(v) {
                var conf = $('confirmation') ? $('confirmation') : $$('.validate-cemail')[0];
                var pass = false;
  var confirm;
                if ($('email')) {
                    pass = $('email');
                }
  confirm =conf.value;
  if(!confirm && $('email2'))
  {
  confirm = $('email2').value;
  }
                return (pass.value == confirm);
            }],
]); 


Add the new js file into your customer.xml file

<reference name="head">
    <action method="addJs"><script>email/validation.js</script></action>
</reference> 

On the register form add a new field to contain the email confirmation field "template/customer/form/register.phtml".

<label class="required" for="email_address"><em>*</em>CONFIRM EMAIL</label>
<div class="input-box"> <input class="input-text required-entry validate-cemail" title="Email Address" value="" id="email2" name="email2" type="text">
</div>

Hope it Helps.. Thanks...

2 comments:

  1. I have tried the code as you said it 1.4 but it does not work even if I keep the correct email in both the fields its says please enter the correct email.
    Please help me what I should do.

    ReplyDelete
  2. please clear your java script cache in back-end and try. for me too the same problem occurred. after i cleared my javascript cache it works fine for me.

    ReplyDelete