folks.
I'm trying to validate a form with jQuery Validate plugin (http://jqueryvalidation.org/) with rangeWords option. My problem is that I need to use comma to separate the words in the form input fields and I need to allow special chars/latin chars like áéíóúàèìòùÀÈÌÒÙÁÉÍÓÚñÑüÜ
Here is my code - index.php
<form method="post" action="" id="submissao_trabalhos_selecao" name="submissao_trabalhos_selecao">
<input name="palavras_chave" type="text" id="palavras_chave" placeholder="palavra 1, palavra 2, palavra 3..." value="" size="60" required />
</form>
<input type="submit" name="salvar" id="salvar" value="Salvar informações para continuar depois" form="submissao_trabalhos_selecao" />
The javascript
$(document).ready(function(){
//this addMethod allows all this chars listed above
jQuery.validator.addMethod("caractereslatinos", function(value, element){
return this.optional(element) || /^[0-9a-zA-ZáéíóúàèìòùÀÈÌÒÙÁÉÍÓÚñÑüÜ_\s]+$/.test(value)
}, "Digite caracteres válidos.");
$("#submissao_trabalhos_selecao").validate({
rules: {
palavras_chave: {required: true, rangeWords:[01, 05], caractereslatinos: true}
},
messages: {
palavras_chave: "Por favor, verifique a quantidade de palavras-chave (de 1 a 5)."
},
submitHandler: function() {
alert();
//$(form).ajaxSubmit();
}
})
});
I don't know why this is not working. When I use the latin chars it's not possible to submit the form.