Email Validation using JQuery (emails matching) [closed]

大憨熊 提交于 2019-12-13 23:15:48

问题


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'
            },
     }

回答1:


Try this way

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"
     }
 }

Working Example




回答2:


$('#email).validate({
  ...
  rules: {
    ...
    'entry[confirm_email]': {
      equalTo: "entry[email]"
    }
  }
});

Here "entry[email]" should be the id of input element!!



来源:https://stackoverflow.com/questions/22758997/email-validation-using-jquery-emails-matching

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!