email()->validate('user-email'); // check for errors if ($validator->hasErrors()) { $_SESSION['errors']['date-range-picker-form'] = $validator->getAllErrors(); } else { $email_config = array( 'sender_email' => 'contact@phpformbuilder.pro', 'sender_name' => 'Php Form Builder', 'recipient_email' => addslashes($_POST['user-email']), 'subject' => 'Date range picker form from Php Form Builder', 'filter_values' => 'date-range-picker-form' ); $sent_message = Form::sendMail($email_config); Form::clear('date-range-picker-form'); } } /* ================================================== The Form ================================================== */ $form = new Form('date-range-picker-form', 'horizontal', 'novalidate', 'foundation'); $form->setMode('development'); // Simple date picker $form->startFieldset('Simple date picker'); $form->addInput('text', 'date-picker', '', 'Choose a date', 'class=litepick, data-number-of-months=1, data-number-of-columns=1, required'); $form->endFieldset(); // Simple date range picker $form->startFieldset('Simple date range picker'); $form->addInput('text', 'daterange-picker', '', 'Choose a date', 'class=litepick, data-single-mode=false, required'); $form->endFieldset(); // Date range picker with min & max date // set minimum date $now = new DateTime('now'); $date_min = $now->format('Y-m-d'); // set maximum date $max = $now->add(new DateInterval('P1M')); $date_max = $now->format('Y-m-d'); $form->startFieldset('Date range picker with minimum & maximum date'); $form->addHelper('The minimum date is set to the current day, the maximum date is one month later.', 'daterange-picker-min-max'); $form->addInput('text', 'daterange-picker-min-max', '', 'Choose a date', 'class=litepick, data-single-mode=false, data-min-date=' . $date_min . ', data-max-date=' . $date_max . ', required'); $form->endFieldset(); // Change the date format $form->startFieldset('Change the date format'); $form->addHelper('The plugin documentation about date formats is available here: https://wakirin.github.io/Litepicker/#option-format', 'daterange-picker-date-format'); $form->addInput('text', 'daterange-picker-date-format', '', 'Choose a date', 'class=litepick, data-single-mode=false, data-format=YYYY-MM-DD, required'); $form->endFieldset(); // Change the language $form->startFieldset('Change the language'); $form->addInput('text', 'daterange-picker-language', '', 'Choisissez une date', 'class=litepick, data-single-mode=false, data-lang=fr-FR, required'); $form->endFieldset(); // Date range with range restricted to minimum 6 days + reset / submit buttons $form->startFieldset('Date range with range restricted to minimum 6 days + reset / submit buttons'); $form->addInput('text', 'daterange-picker-6-days', '', 'Choose start / end dates', 'class=litepick, data-single-mode=false, data-min-days=5, data-auto-apply=false, data-use-reset-btn=true, required'); $form->endFieldset(); // Date range in 2 separate fields + formatted dates $form->startFieldset('Date range in 2 separate fields + formatted dates'); $date_start_field_name = 'date-start'; $date_end_field_name = 'date-end'; $form->groupInputs($date_start_field_name, $date_end_field_name); $form->setCols(4, 4); $form->addInput('text', $date_start_field_name, '', 'Choose start / end dates', 'class=litepick, data-single-mode=false, data-format=YYYY-MM-DD, data-element-end=' . $date_end_field_name . ', required'); $form->setCols(0, 4); $form->addInput('text', $date_end_field_name, '', '', 'readonly, required'); $form->endFieldset(); // Date range in 2 separate fields + formatted dates + independent pickers + disabled dates $form->startFieldset('Date range in 2 separate fields + formatted dates + independent pickers + disabled dates'); $date_start_field_name = 'date-start-2'; $date_end_field_name = 'date-end-2'; // set booked days from (now + 5 days) to (now + 10 days) $now = new DateTime('now'); $now_plus_5days = $now->add(new DateInterval('P5D')); $booked_start = $now_plus_5days->format('Y-m-d'); $now = new DateTime('now'); $now_plus_10days = $now->add(new DateInterval('P10D')); $booked_end = $now_plus_10days->format('Y-m-d'); // add a single booked date $now = new DateTime('now'); $now_plus_15days = $now->add(new DateInterval('P15D')); $booked_single = $now_plus_15days->format('Y-m-d'); $form->groupInputs($date_start_field_name, $date_end_field_name); $form->setCols(4, 4); $form->addInput('text', $date_start_field_name, '', 'Choose start / end dates', 'class=litepick, data-single-mode=false, data-format=YYYY-MM-DD, data-element-end=' . $date_end_field_name . ', data-disallow-booked-days-in-range=true, data-booked-days=[[\'' . $booked_start . '\'\, \'' . $booked_end . '\']\, \'' . $booked_single . '\'], required'); $form->setCols(0, 4); $form->addInput('text', $date_end_field_name, '', '', 'readonly, required'); $form->endFieldset(); $form->startFieldset(); $form->setCols(4, 8); $form->addInput('email', 'user-email', '', 'Your Email', 'placeholder=Email, required'); $form->addBtn('submit', 'submit-btn', 1, 'Submit', 'class=success button'); $form->endFieldset(); // jQuery validation $form->addPlugin('formvalidation', '#date-range-picker-form'); ?> Foundation Date range picker Form - How to create PHP forms easily printIncludes('css'); ?>

Php Form Builder - Foundation Date range picker Form
with the litepicker picker plugin

The Litepicker plugin (date range plugin) has a lot of options available. This form shows examples of common use cases.
More options and explanations are available in the documentation

render(); ?>
printIncludes('js'); $form->printJsCode(); ?>