1

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;" />
0

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

4
  • @Waquar by default magento not providing? I mean for this class="input-text required-entry validate-email" not possible? – User0434 Dec 9 '19 at 11:10
  • please see my updated answer – Waqar Ali Dec 9 '19 at 11:31
  • it is not working..I placed like this <input type="text" name="confirm_email" id="confirm_email" class="input-text" data-validate="{required:true, 'validate-email':true,equalTo:'#useremail'}" > – User0434 Dec 9 '19 at 11:42
  • can you check in your "<form" element data-mage-init='{"validation":{}}' is there or not ? – Shailesh Katarmal Dec 9 '19 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.