I have a form that is composed of four inputs
and they are grouped in pairs.
The rule for this form is very simple, if I fill one of the inputs of the pair, I have to fill in the other one too or do not fill in any. To achieve this behavior I used the skip_or_fill_minimun
method.
HTML:
<div id="msgErros"></div>
<form>
<label for="dataInicial">Data Inicial</label>
<input type="text" name="filtro.dataInicial" id="dataInicial" class="datas" />
<label for="dataFinal">Data Final</label>
<input type="text" name="filtro.dataFinal" id="dataFinal" class="datas" />
<br />
<label for="tempoInicial">Tempo Inicial</label>
<input type="text" name="filtro.tempoInicial" id="tempoInicial" class="tempos" />
<label for="tempoFinal">Tempo Final</label>
<input type="text" name="filtro.tempoFinal" id="tempoFinal" class="tempos" />
<br />
<button type="submit">Enviar</button>
</form>
Validation rules, messages, and groups:
$("form").validate({
rules : {
"filtro.dataInicial": {
skip_or_fill_minimum: [2, ".datas"]
},
"filtro.dataFinal": {
skip_or_fill_minimum: [2, ".datas"]
},
"filtro.tempoInicial": {
skip_or_fill_minimum: [2, ".tempos"]
},
"filtro.tempoFinal": {
skip_or_fill_minimum: [2, ".tempos"]
}
},
messages: {
"filtro.dataInicial": {
skip_or_fill_minimum: "Por favor, preencha ambos os campos de data ou nenhum deles."
},
"filtro.dataFinal": {
skip_or_fill_minimum: "Por favor, preencha ambos os campos de data ou nenhum deles."
},
"filtro.tempoInicial": {
skip_or_fill_minimum: "Por favor, preencha ambos os campos de tempo ou nenhum deles."
},
"filtro.tempoFinal": {
skip_or_fill_minimum: "Por favor, preencha ambos os campos de tempo ou nenhum deles."
}
},
groups : {
grupoDatasAtendimentoSintetico : "filtro.dataInicial filtro.dataFinal",
grupoTemposAtendimentoSintetico : "filtro.tempoInicial filtro.tempoFinal"
},
errorContainer : "#msgErros ul",
errorLabelContainer : "#msgErros",
wrapper : "li"
});
The problem is that if I fill in one of the first two inputs the rule is not triggered, the problem does not occur if I do this with the second pair. If I delete the second pair the rule runs perfectly, so I think it's a bug. Here's a fiddle .
I read about this method and require_from_group
causing problems that simply prevent other methods from running, but this bug was supposedly fixed in version 1.11.1, which is what I'm using in my project and not fiddle both for the plugin itself and its additional methods.
The problem only happens when the user fills in one of the fields in the first pair. Does anyone know if this is another bug? I did not find anything related to this in the GitHub issue tracker of this plugin.
UPDATE:
Create an entry in the issue tracker of the plugin at: link .