2
I am using the jQuery Validate plugin to validate a form. When I declare the rules in the input declaration the form turns red when it doesn’t fit, and blue when it fits. Here is an example of an input declaration with in-line 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 do the validation through a function, the form does not receive the styling. I think it’s something from Bootstrap or something similar. Follow example of validation through 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’d like to know is if there’s a way for me to do the styling myself using function validation or some result that it provides.
Yeah, I forgot to put a comma here
– Anderson Amorim
But as for what I asked, there’s something to be done?
– Anderson Amorim
I did the Jsfiddle test of your code and implemented some fixes. see if it works link By default jQueryValidate enters the class error the input that did not pass the validation and Valid if you pass. You only need a css to control the colors
– Pablo Carvalho
Thanks Pablo, through your test I managed to perform the stylization I wanted in my form! = D
– Anderson Amorim
Ok, Anderson. Help other users who experience the same situation by signaling my answer as accepted. Abs
– Pablo Carvalho