I have a problem that is as follows, I have the fields: Name, Age and Text;
In a part of the system I register that the Text field will only appear if the Name field is equal to PH
and the Age field has the value 20
with both true conditions and then I release the Text field. / p>
My difficulty in this part is because it can have many fields because the form is set up by the client, ie the client can register 20, 30 fields for this form and all have a specific rule to release some other field. Is there a plugin that checks or does this type of validation?
At this point I tried the following, but it only validated this way if it was 1 to 1. But in this case it can be N-1
or 1-N
or would it be better to create an intermediate table for this action?
$(function () {
var campoDependente = '#codigo_<?php echo $condicao->atividade_campo_dependente ?>',
campoTrigger = '#codigo_<?php echo $condicao->atividade_campo ?>',
valor = '<?php echo trim($condicao->condicao) ?>';
function mostrar() {
var val = '';
var checkbox = $(campoTrigger + ' input:checked');
var select = $(campoTrigger + ' select > option:selected');
var input = $(campoTrigger + ' input');
if (checkbox.length > 0) {
val = $.trim(checkbox.parent().text());
} else if (select.length > 0) {
val = $.trim(select.text());
} else {
val = input.val();
}
if (val == valor) {
$(campoDependente).css('display', 'inline-block');
} else {
$(campoDependente).css('display', 'none');
}
}
mostrar();
$(campoTrigger).change(mostrar);
});