This has been added to webform validation Validate greater than or less than other field but I do not understand how you compare and validate 2 date components using the comparison option.

My steps:

I checked Departure date component box (1)
I checked Return date component box (2)

In the comparison operator field which asks to use one of these operators: >, >=, <, <=

To test I just entered < and assumed it would check the date entered for Departure and validate that the Return date was less than the Departure date since it will compare the first component with the second using this operator.

I tested using a Departure date that was after the Return date and the form submitted without error.

What exactly should go in this comparison operator field to compare two date components so that one date is 2 days ahead of the other component?

I reviewed the information here https://www.drupal.org/node/2168813 for regular expressions but still not clear on correct usage in this field. As I understand it's supposed to allow you to validate that a date is greater than another.

Thanks

Comments

lsabug created an issue. See original summary.

Liam Morland’s picture

It can validate that number or date is greater, but not greater by a certain amount or at least a certain amount. That would be a neat feature to add. You will probably have to write a custom validator, which is not difficult.

Liam Morland’s picture

Status: Active » Fixed

If you need more help, please re-open and provide details.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mhentry’s picture

I am also stuck with the same situation. In webform I have two date fields D1 and D2.
D1 field shows the current date and D2 field always has to show +3 days from D1. (D2 must always be +3 days > D1 field )

I need to achieve: When user change the date of D1 field to future and try to submit, form has to through error saying D2 field has to be +3 days ahead of D1 field.

Liam Morland’s picture

Same answer: That functionality is not supported. You could write a custom validator to do that.