Home › Forums › Quform WordPress › Validating a date against another form value
- This topic has 7 replies, 2 voices, and was last updated 11 years, 3 months ago by Ally.
- AuthorPosts
- August 20, 2013 at 5:12 pm #5885ebernhardParticipant
Hi Guys,
I have read the date validation guide (https://support.themecatcher.net/quform-wordpress/guides/advanced/date-validation) I would like to know if somebody knows how to make the booking period at least 6 night. So it will not be possible to book less nights.
Hope that somebody can assist me here
Thanks and regards,
EricAugust 21, 2013 at 1:26 pm #5892AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 22, 2013 at 12:55 pm #5926ebernhardParticipantHi Ally,
Thank you for your quicj reply, I added the code to the functions.php file but I still can book for 2 nights.
The form_id is 20 and the start date is field iphorm_20_29 and the end date is 20_47 so I changed your code to the following
function mytheme_check_date_range($valid, $value, $element)
{
// Get the value of the start date element
$startDate = $element->getForm()->getValue(‘iphorm_20_29’);$startDate = strtotime("{$startDate[‘year’]}-{$startDate[‘month’]}-{$startDate[‘day’]} 00:00:00");
$sixDaysAfterStart = strtotime("+6 days", $startDate);
$endDate = strtotime("{$value[‘year’]}-{$value[‘month’]}-{$value[‘day’]} 23:59:59");if ($sixDaysAfterStart > $endDate) {
$element->addError(‘You must book at least 6 days’);
$valid = false;
}return $valid;
}
add_filter(‘iphorm_element_valid_iphorm_20_47’, ‘mytheme_check_date_range’, 10, 3);What am I doing wrong?
Hope you can assist me once more
August 23, 2013 at 10:27 am #5971AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 28, 2013 at 9:01 pm #6073ebernhardParticipantHi Ally,
I was away for a few days. I have just now send you a private email via codecanyon
Hope you can solve the issue.
Best regards,
EricAugust 29, 2013 at 12:50 pm #6085AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 29, 2013 at 12:57 pm #6088ebernhardParticipantHi Ally,
Great thanks very much!!
if I want this to be valid to other forms do I just copy the code and change the form id’s?Regards,
EricAugust 29, 2013 at 1:12 pm #6090AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.