Start a conversation

Validating partial dates NK/MM/YYYY

In some cases only partial dates are known. For example only the month and the year is known. In this case you can create a text field and add a calculation field to make sure that the date is in the correct format. 

Use the following template to check for the date format DD/MM/YYYY and validate the date when only month and year is known NK/MM/YYYY:

var regex = /^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[012])\/(19|20)[0-9]{2}|NK\/(0[1-9]|1[012])\/((19|20)[0-9]{2})/;
var date = "{your_text_field}";
if (regex.test(date)) {
    "The date is in the correct format."
} else {
   "Date must be in one of the following formats: DD/MM/YYYY or NK/MM/YYYY."
}

Test the template in the calculation helper.

Alternative solution to adding partial dates in Castor EDC would be to create several dropdown field for day, month and year and mark missing data:

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Castor Support Team

  2. Posted