使用JQuery的电子邮件验证(电子邮件匹配)

使用JQuery的电子邮件验证(电子邮件匹配)

问题描述:

我在表单上使用以下验证,因为我有一个email address字段和confirm email address字段,我需要一些验证以确保这两个字段匹配,我目前有以下内容,这给了我错误消息即使它匹配也不匹配,有人知道为什么会这样吗?

I am using the following validation on my form, as i have a email address field and confirm email address field i need some validation to make sure these two fields match, i currently have the following which is giving me the error message that it does not match even when it does, anyone know why this could be?

rules: {
            'entry[email]': {
                required: true,
                email: true
            },
            'entry[confirm_email]': {
            //  required: true,
                equalTo: "entry[email]"
            },
},
        messages: {
            'entry[email]': {
                required: ' Please enter a valid email address',
                minlength: 'Not a valid email address'
            },
            'entry[confirm_email]': {
                required: ' Please make sure email matches above',
                minlength: 'Does not match above email address'
            },
     }

尝试这种方式

rules:{
    pwd:{
         required:true //First email section
    },
    pwd1:{
        required:true,//Second email section
        equalTo: "#same" //Use id of the first email text box here
        }   
    },
 messages:{
    pwd1:{
        equalTo: "Must be same as above email"
     }
 }

工作示例