Date validation (DD/MM/YYYY) in form field or single line text entry failing | XM Community
Skip to main content

So I have a few conditions I have trying to implement into a form field question (and after much headache, trying with two different single-line text entry question too). Here are the conditions for two fields - Start Date and End Date (or two questions if that be the case):

1. End date has to be after the Start date

2. Start date has to be on or after 17/04/2026

3. End date has to be on or before 31/03/2029

I have tried implementing Javascript conditions (and disabling all in-built Validation/Response Requirements) to test incorrect entries, and that worked to an extent with a pop-up which comes when I click Next. However, if I click ‘Ok’ in that box, it proceeds and accepts the incorrect entry anyway.

 

Now I am back to square one and feel like keep it simple with the in-build validation condition. The only issue is that if I create a Custom Validation for dates (so Start date >= 17/04/2026 AND End date <= 31/03/2029 in the form field) it seem to only read the DD part as a comparison, i.e., basically does not render the entries as dates. Very stumped on how BEST to implement this and open to all advice!

@LaurenTaylor,

You can use JS change the text fields to date fields, which allows you to set min and max dates for the date picker. The dates will be stored in YYYY-MM-DD but will be displayed based on the browser’s locale (in your case dd/mm/yyyy). The YYYY-MM-DD format makes it easy to do comparisons.

JS:

Qualtrics.SurveyEngine.addOnload(function() {
this.getQuestionContainer().querySelectorAll("inputntype=text]").forEach(el => {
el.setAttribute("type","date");
el.setAttribute("min","2026-04-17");
el.setAttribute("max","2029-03-31");
});
});

Custom Validation:

Start is Less Than or Equal to {piped value of End}

AND Start is Greater Than or Equal to 2026-04-17

AND End is Less Than or Equal to 2029-03-31


Leave a Reply