Check field content depending on other field entries
$30-250 USD
Completed
Posted over 13 years ago
$30-250 USD
Paid on delivery
I have already an online booking form. The Form works fine now and I would like to add on one more issue, but the code ignores what I want to check. I have 4 fields: "arrival", "departure", "no. of persons" and "comments" to check.
Scenario 1:
All field mentioned above are empty: Workes fine and message appears: "You have not provided any booking details".
Scenario 2:
If arrival (date_start) and departure (date_end) is entered, there should be at least an entry either in the field "comment", or in the field "pax". If not, there should be a message: "You have not provided sufficient booking details".
INSTEAD: The form is sent, which should NOT be the case !
The code is currently:
# all fields are empty : arrival, departure, pax and comments ==> error (works fine)
if(empty($data_start) && empty($data_end) && empty($pax)&& empty($comment)){
exit("You have not specified any booking details");
exit;
}
#If arrival and departure date is entered, there should be at least an entry either in the field "comment", or in the field "pax".
if(!isset($data_start) && !isset($data_end) && empty($pax) && empty($comment)){
exit("You have not provided sufficient booking details.");
exit;
}
The form is attached and can be tested at [login to view URL]
Can someone please check and tell me what's wrong with the code ?
I've taken a look and it's quite simple to fix the code to do what you want. Do you also want to modify the web-page code so that a message box comes up (similar to invalid email, name, or verification) stating that no booking information has been entered?
$30 USD in 1 day
5.0 (1 review)
1.0
1.0
11 freelancers are bidding on average $31 USD for this job