Skip to main content
Answered

Relative Date Validation

  • 16 February 2021
  • 6 replies
  • 1355 views

Relative Date Validation

I’d like to be able to validate the answer to a Date Question, so that only the following is accepted:

  • Current or next week
  • Excluding ‘today’ and ‘tomorrow’
  • Excluding weekends, so Saturday and Sunday

In other words, where today is ‘t’, t+2 to t+14 excl. weekends. All other dates would then be routed to an ‘error’ page. Any tips or tricks to help me out here?

 

P.S. I know that I could manually update a Typeform daily, but that creates an excessive amount of work and a high risk of manual error.

Hi @dan - thanks for stopping by the community! 🙂 While we don’t currently have this feature in our builder, we’ll note this suggestion. 🙂 I’m not sure of any fancy workarounds for this, but possibly @picsoung knows of one!


Logic and dates is definitively a hard subject.
But we recently implemented ways to compare dates in the Logic panel.
Here is an example.


Sadly this currently only works with constant dates, and not dynamically yet with things like today, tomorrow


But if you are up for an adventure there might be a workaround using our APIs :)

Those logic jumps are defined in the logic part of your form definition, available on https://api.typeform.com/forms/YOUR_FORM_ID


And they look like this

{
"action": "jump",
"details": {
"to": {
"type": "field",
"value": "ID_OF_FIELD_WHERE_TO_JUMP"
}
},
"condition": {
"op": "later_than",
"vars": :{
"type": "field",
"value": "ID_OF_FIELD_WITH_DATE"
},
{
"type": "constant",
"value": "A_DATE_YYYY-MM-DD"
}
]
}
}

Once workaround for now could be to have a script daily that updates the logic jump part of your form with the relevant dates.

You would use the Update Form endpoint of our API.

I built something similar to update dates in a dropdown.


Ooo thank you @picsoung !!


We use typeform for Event Requests within our organization.
We would like to ONLY allow requests that are 4+ weeks out.
Is it possible to have a “calendar/date” question that DOES NOT allow the date to be selected within a certain time frame?

 

Thanks!


Hi @fallonmichaeltx. Happy Wednesday :hugging:

 

I moved your question to this conversation so you can check the thread and the workaround suggested here 🙂 Hope this helps! 


Hi, I’m new to Typeform and wondering if there’s a way for clients to choose a date to book a birthday party slot and then make that date unavailable to other form users once all slots that day are filled. 

Understand this might not be do-able but wanted to check! Thank you 


Reply