I have a form where the user is asked to enter a start date and an end date for a reservation. How can I validate that the end date is always after the start date?
WordPress Forms
I have a form where the user is asked to enter a start date and an end date for a reservation. How can I validate that the end date is always after the start date?
Formidable is by far the best contact form I have seen for WordPress. It is easy to create and has had 0 issues with form deliveries. What makes Formidable unique is it’s ease of use and reporting capabilities. Takes all of the guess work out building a form.
Chris (Level3Logic)The tool is very easy to use, customizable, visually appealing and just plain simple.
Craig Elliott (QR2 Marketing)Copyright © 2013 Strategy11, LLC
August 21, 2012 at 9:21 pm
This can be done by adding some extra code to a new plugin or your theme functions.php. Something like this:
add_filter('frm_validate_field_entry', 'my_custom_validation', 10, 3); function my_custom_validation($errors, $posted_field, $posted_value){ if($posted_field->id == 25){ //change 25 to the ID of the start date field if(strtotime($_POST['item_meta'][29]) < strtotime($posted_value)){ //if value of field 29 is less than field 25, then it's wrong. Change 29 to the ID of your end date field //if it doesn't match up, add an error: $errors['field'. $posted_field->id] = 'That field is wrong!'; } } return $errors; }Topic closed.