Skip to content

Instantly share code, notes, and snippets.

@speedupmate
Created December 11, 2013 14:46
Show Gist options
  • Save speedupmate/7911608 to your computer and use it in GitHub Desktop.
Save speedupmate/7911608 to your computer and use it in GitHub Desktop.
Create e-mail matching validation field
<?php if(!$this->isCustomerLoggedIn()): ?>
<?php $billingFields['email'] = $billingFields['email'].'
<div class="input-box input-email'.((in_array('email', $formErrors)) ? ' input-error' : '').'">
<label for="billing:email">'.$this->__('Email Address').' <span class="required">*</span></label><br />
<input type="text" name="billing[email]" id="billing:email" value="'.$dataHelper->clearDash($this->getQuote()->getBillingAddress()->getEmail()).'" title="'.$this->__('Email Address') .'" class="validate-email required-entry input-text" />
</div>
<div class="input-box input-email-repeat'.((in_array('email', $formErrors)) ? ' input-error' : '').'">
<label for="billing:email-repeat">'.$this->__('Retype Email Address').' <span class="required">*</span></label><br />
<input type="text" name="billing[email-repeat]" id="billing:email-repeat" value="'.$dataHelper->clearDash($this->getQuote()->getBillingAddress()->getEmail()).'" title="'.$this->__('Repeat Email Address') .'" class="validate-cemail required-entry input-text" />
</div>
<script>
Validation.add("validate-cemail", "'.$this->__('Please make sure that you have typed a matching e-mail address').'", function(v) {
var vemail = $("billing:email").getValue();
var vcemail = $("billing:email-repeat").getValue();
return (vemail == vcemail);
});
</script>';
?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment