Match two fields with jQuery validate plugin

后端 未结 3 1115
小鲜肉
小鲜肉 2020-12-06 03:52

I have an e-mail field, and a confirm e-mail field. I need to validate both of them to make sure their values match.

Is there a way to add a rule to match those two

3条回答
  •  一向
    一向 (楼主)
    2020-12-06 04:53

    You could use the equalTo method:

    $('#myform').validate({
        rules: {
            email: 'required',
            emailConfirm: {
                equalTo: '#email'
            }
        }
    });
    

提交回复
热议问题