Question

I have 2 fields in form .

1.user email 
2.confirm email.

If I fill on user email field and moved to confirm email field then enter wrong email i.e; not same as user email, it is showing error "both emails should be same" so in this scenario, it is corect.

other scenario

If I fill on user email field and moved to confirm email field then enter same as user email then edit user name to some other name but it is not showing error message

I need error message on this scenario as well

    <input 
       name="useremail" 
       id="useremail" 
       title="<?php echo $this->__('User Email') ?>" 
       value="" class="input-text required-entry validate-email"                   type="text" />

    <input 
       type="text" 
       name="confirm_email" 
       id="confirm_email" 
       title="<?php echo $this->__('Confirm Email') ?>" 
       class="input-text required-entry validate-cemail" 
       value="" onpaste="return false;" />
Was it helpful?

Solution

if you want to use simple jquery you can do something like that

function confirmcheck(){
   var email= $('#useremail').val(); 
   var confirmemail= $('#confirm_email').val();    
   if(email==confirmemail){
      $('.alert').html('<span>email and password are same</span>');
   }
}
$('#useremail').on('change',function(){
  confirmcheck();
});
$('#confirm_email').on('change',function(){
  confirmcheck();
});

Update: 1

data-validate="{required:true, 'validate-email':true,equalTo:'#email'}"

For Detail You can see Here

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top