1
I have the following function:
function valida_valor2($str)
{
$count = strlen($str);
if (($count > 19) OR (!is_numeric($str))) {
return "INVALIDO";
}else {
return $str;
}
}
When I call her in my code returns INVALIDO
in the following call: Where the variables $valor_iem9... = 0;
if ((valida_valor2($valor_iem9_f_a) == 'INVALIDO') || (valida_valor2($valor_iem9_f_b) == 'INVALIDO') || (valida_valor2($valor_iem9_f_c) == 'INVALIDO') || (valida_valor2($valor_iem9_f_d) == 'INVALIDO') || (valida_valor2($valor_iem9_f_e) == 'INVALIDO')) {
echo "Campo IEM9 Pessoa Física inválido";
exit;
}
Some light?
Try to use
AND
instead ofOR
, to verify that the two conditions are met.– Jonathan Willian
You want to validate only nothing dot digits or trace right?
– rray
Yes. I want to enter digits.
– olifreitas
The function itself I believe is right but I’m in trouble at the time I call.
– olifreitas
Actually when you pass the '0' by the function it does not interpret as an 'int', convert the value to string before using in the function.
– Jonathan Willian