How to add email confirmation field on checkout page?

by Peter D.

You can add the following code to the custom javascript file of your theme:

document.observe('dom:loaded', function() {
  var email = $('billing:email');
  if (!email || !email.up('li')) {
    return;
  }

  email.up('li').insert({
    'after': '<input placeholder="Enter your email again please" class="input-text required-entry validate-both-emails" type="text">'
  });

  Validation.add(
    'validate-both-emails',
    'Email did not match the email above',
    function(v, input) {
      var dependentInput = $('billing:email'),
          isEqualValues  = input.value == dependentInput.value;

      if (isEqualValues && dependentInput.hasClassName('validation-failed')) {
        Validation.test(this.className, dependentInput);
      }

      return isEqualValues;
    }
  );
});

Recent articles

Back to top