Is it possible to have some validation rules on DATE type fields?
For example, where the date is NOT allowed to be later than today? or where the date is NOT allowed to be greater than 12 months ago?

Getting more technical, perhaps where the difference between two dates is NOT allowed to be more than 90 days? (Although this falls into the category of multiple field validation perhaps).

I have also noted that when I create a default value in a date field (of TODAY for example) and the field is NOT set to TEXT (it creates 3 drop down lists for Day Month and Year) the default value is NOT displayed. I'd rather have the drop down list for users rather than a text version in which they can use differing date formats.

I have been fortuneate enough to have a Java programmer provide some script that overcomes *my* issues with date validation (may that man be blessed with as much coffee as he requires).

We are using Drupal 6..

Comments

pbarrientos’s picture

Hi!
I just went into the same trip and found this solution!

You need to add a condition to your rule and then select "Execute custom PHP code"
Then you add something like this:

$condition = FALSE;
if(date("Y-m-d\TH:i:s", time()) > Your-field-date){
$condition = TRUE;
}
return $condition;

This condition only compares that your date is less (before) than today to make it returns true.

Hope it works!

/Drupal begginer

dahousecat’s picture

For Drupal 7 to validate that a date entered is in the past the following code worked for me:

if(strtotime($this->value)>time()) {
	form_set_error('field_date', 'The date entered is in the future');
}

See this page for more info on PHP validation.

Liam Morland’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 is no longer supported. If this issue exists in a later version of webform_validation, please re-open and update the version number.