1
I have this code to check if it is a numeric value and I have tried that the maximum value of digits is 9. I also tried with != or ==
What I tried:
Option 1
//php verif phone
if(isset($_POST["phone"])){
if (strlen($phone) != 9) {
if (!$phone) {
$errors[] = "Indique um número válido.";
}elseif ( !is_numeric( $phone )) {
$errors[]= "Verifique novamente o número.";
}
}
Option 2
//php verif phone
if(isset($_POST["phone"]) != 9){
if (!$phone) {
$errors[] = "Indique um número válido.";
}elseif ( !is_numeric( $phone )) {
$errors[]= "Verifique novamente o número.";
}
}
Option 3
//php verif phone
if(isset($_POST["phone"])){
if (!$phone) {
$errors[] = "Indique um número válido.";
}elseif ( !is_numeric( $phone ) != 9) {
$errors[]= "Verifique novamente o número.";
}
}
I searched here and via google and supposedly for what I read should give. But so far it forces me to have 10 digits, and not 9 as is my goal.
<label for="phone"></label>
<input name="phone" type="tel" id="phone" size="9"
value="" placeholder="Telemóvel"
class="required digits" title="Verifique novamente o número.">
What happens that the code does not work, from an input example, tbm, if the phone is formatted will not be interpreted as number.
– rray
That field requires me to have 10 digits, otherwise it tells me to check the number.
– APDB