Error message for email and confirm email validation
-
22-03-2021 - |
Pregunta
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;" />
Solución
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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange