Hello,
I have a php form which takes phone numbers.
I have a text box for landline and a text box for mobile numbers. Only one of the text boxes needs to be filled out.
How do I validate in PHP to make sure one of them is filled out. I am sure it is obvious but I just can't work it out.
Sorry if it is a little confusing. Hope someone can help.
Thanks
I want to try and avoid java script because I am not very strong at it. I was thinking something like the following:
$landline = $_POST['landline'];
$mobile = $_POST['mobile'] ;
if ( ! empty( $landline ) && ! empty( $mobile ) ) {
$contacterror = 'you need to enter at least one contact number';
}
else
{
$contacterror = 'One or more text boxes have been filled out';
}
I have a php form which takes phone numbers.
I have a text box for landline and a text box for mobile numbers. Only one of the text boxes needs to be filled out.
How do I validate in PHP to make sure one of them is filled out. I am sure it is obvious but I just can't work it out.
Sorry if it is a little confusing. Hope someone can help.
Thanks
I want to try and avoid java script because I am not very strong at it. I was thinking something like the following:
$landline = $_POST['landline'];
$mobile = $_POST['mobile'] ;
if ( ! empty( $landline ) && ! empty( $mobile ) ) {
$contacterror = 'you need to enter at least one contact number';
}
else
{
$contacterror = 'One or more text boxes have been filled out';
}