hi somebody knows how to validate fields with jquery validate using attribute class and not using the attribute name, this also because i generate fields dynamically, example:
<input type="text" id="Nombre_1" name="Nombre_1" class="obligatorios" />
<input type="text" id="Nombre_2" name="Nombre_2" class="obligatorios" />
<input type="text" id="Nombre_3" name="Nombre_3" class="obligatorios" />
<input type="text" id="Nombre_4" name="Nombre_4" class="obligatorios" />
etc........
i usually have to do something like this but i do not know how many fields would be generated.
$('#mi_form').validate({
rules: {
Nombre_1: {
required: true
},
Nombre_2: {
required: true
},
Nombre_3: {
required: true
},
Nombre_4: {
required: true
}
},
messages: {
Nombre_1: {
required: 'Campo Obligatorio'
},
Nombre_2: {
required: 'Campo Obligatorio'
},
Nombre_3: {
required: 'Campo Obligatorio'
},
Nombre_4: {
required: 'Campo Obligatorio'
},
}
,
submitHandler: function(form) {
form.submit();
}
});
so i was thinking in attribute class to add when i add a new field and use this way to validate, but i have not found and example that works, thank you