Stylize input via jQuery Validate

2

I'm using the jQuery Validate plugin to validate a form. When I declare the rules in the input declaration the form turns red when it does not fit the same, and blue when they fit. Here is an example of an input statement with inline rules:

<div class="input-prepend">
                    <span class="add-on"><i class="icon-user"></i></span>
                    <input class="span4" id="nome" size="16" name="nome" type="text" placeholder="Nome" required minlength="2">
</div>

However, when I validate through a function, the form does not receive stylization. I think it's something Bootstrap or something similar. Here is an example of validation through the function:

        <script type="text/javascript">
        $(document).ready( function() {
           $("#idCadastro").validate({
            rules: {
                nome: {
                    required: true, minlength: 2
                }
            messages: {
                nome: {
                    required: "Digite o seu nome", minLength: "O seu nome deve conter, no mínimo, 2 caracteres"
                }
           });
        });
      </script>

What I would like to know is if I have to do the stylization myself using function validation or some result that it provides.

    
asked by anonymous 18.05.2017 / 17:45

2 answers

1

The structure of the object you are passing to the Validate () function appears to be wrong. rules {}, messages {} must be separate. As it did, the message object appears to be the child of the rules object. I suggest you take a cool look at the pluguin documentation you are using and see how this object mounts correctly.

In this link you can test and see the implementation of a working JQueryValidate link

I hope I have helped.

    
18.05.2017 / 18:28
0

Hello, here is the link where we have an example of using Jquery validate ... Accessing the Site

    
18.05.2017 / 18:12