0

I have the following jquery validate configuration:

$('form[name=register_form]').validate({
            rules: {
                email: {
                    required: true,
                    email: true
                },
                password: {
                    minlength: 3,
                    maxlength: 15
                },
                confirm_password: {
                    minlength: 3,
                    maxlength: 15,
                    equalTo:"#password"
                }
            },
            messages: {
                email: "You should input real email adress!"
            }
}

As you can see fields password and confirm_password have 2 restrictions.

1. length 3 -15  
2. Its should be equal.

Can you advise how to override both these messages ?

P.S.

When I write the following config:

 messages: {
                email: "invalid email",
                password: "too simple password",
                confirm_password: "too simple password",
                equalTo: "wrong password confirmation"
            }

Even if my passwords has length equals 10 but different I see message too simple password

Sparky
  • 98,165
  • 25
  • 199
  • 285
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • The `messages` option has the exact same object literal structure as the `rules` option. Under `messages` you've simply listed three field names and one method. The method name **must** be defined *under* its corresponding field name, just like you've done for `rules`. Please carefully review [the answer below](http://stackoverflow.com/a/31526517/594235). – Sparky Jul 20 '15 at 22:18

1 Answers1

2

Try this:

messages: {
    password: {
        minlength: 'Your password must be at least 3 characters long',
        maxlength: 'Your password cannot exceed 15 characters',
        equalTo: "wrong password confirmation"
    }
}
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
Joe Attardi
  • 4,381
  • 3
  • 39
  • 41