Byron R.
Byron R.

Reputation: 11

XFDL Date Constraints

I have a form, and on the form it requires a date. The date must be on YYYY-MM-DD format and be on or after 2022-04-01. I am using XFDL and XForms. The only ref I can find in the source code for date is,

<xforms:bind nodeset="instance('INSTANCE')/CertificatonDt" constraint=".='' or substring(., 1, 4) = '2020'" required="true()">

Do I just change the 2020 to 2022?

Upvotes: 1

Views: 108

Answers (1)

Alain Couthures
Alain Couthures

Reputation: 1523

Yes! Using XPath 1.0, the substring() fonction will extract the year from the string representing it.

The current expression is just allowing 2020 as year. If you need a more sophisticated test, you have to replace it with something like . = '' or (number(substring(., 1, 4)) = 2022 and number(substring(., 6, 2)) >= 4) or number(substring(., 1, 4)) > 2022

Upvotes: 1

Related Questions