I'm using the jQuery Validate library to do some validations on a form and would like to know if anyone knows how it could make the focus always stay in the field, in case it is invalid. Currently, it exits the invalid field but does not let it submit until corrected. Here is the code:
$(document).ready( function() {
$("#cadastro").validate({
// Define as regras, pega sempre pela ID. Se não passar (caso do combo) usa o Name.
rules:{
cracha:{
// ordem será obrigatório (required), numérico e terá tamanho mínimo (minLength)
required: true, number: true, minlength: 4
}
},
// Define as mensagens de erro para cada regra
messages:{
cracha:{
required: "Passe o crachá! ",
number: "Somente numeros!",
minlength: "Minimo 4 digitos!"
}
}
});
});
Any ideas?