1
I own a formand in it I have two checks, they are defined by these names:
$checkFin and $checkDep, if any of these checks are checked, the fields corresponding to them must be filled in.
I did the validation but the same is failing and I do not know if the form I did is more indicated or even the correct form, the verification I am doing so:
// FINANCIAMENTO
if (isset($checkFin)) {
if (empty($BancoFinanc)):
$retorno = array('codigo' => 0, 'mensagem' => ' Opção Financiamento marcada, por favor preencha o banco!');
echo json_encode($retorno);
exit();
endif;
}
// DEPÓSITO BANCÁRIO
if (isset($checkDep)) {
if (empty($BancoDepCta)):
$retorno = array('codigo' => 0, 'mensagem' => ' Opção Depósito Bancário marcada, por favor preencha o Banco!');
echo json_encode($retorno);
exit();
endif;
if (empty($Agencia)):
$retorno = array('codigo' => 0, 'mensagem' => ' Opção Depósito Bancário marcada, por favor preencha a Agência!');
echo json_encode($retorno);
exit();
endif;
if (empty($ContaCorrent)):
$retorno = array('codigo' => 0, 'mensagem' => ' Opção Depósito Bancário marcada, por favor preencha a ContaCorrent!');
echo json_encode($retorno);
exit();
endif;
if (empty($Correntista)):
$retorno = array('codigo' => 0, 'mensagem' => ' Opção Depósito Bancário marcada, por favor preencha o Correntista!');
echo json_encode($retorno);
exit();
endif;
if (empty($CPFCNPJ)):
$retorno = array('codigo' => 0, 'mensagem' => ' Opção Depósito Bancário marcada, por favor informe CPF/CNPJ o banco!');
echo json_encode($retorno);
exit();
endif;
}
The fault that is occurring is that when marking the second check $checkDep and not filling any field corresponding to it the script is giving me the message of the first check.
Of the one
print_r($_POST);to see what comes.– rray
Tip, if the operations are exclusionary you can exchange the checkbox for a radio and already leave a value by default, this ensures that the value of the action will always be sent, then just check if it is deposit or financing.
– rray
Hello @rray, thanks for the tip, strange that if I receive the variable $_POST['chkFinancing'] and assign to $checkFin the same is 'null'.
– adventistapr
Put the form in the question.
– rray