使用JQuery的电子邮件验证(电子邮件匹配) [英] Email Validation using JQuery (emails matching)

查看:122
本文介绍了使用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"
     }
 }

工作示例

这篇关于使用JQuery的电子邮件验证(电子邮件匹配)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆