In some cases, only partial dates are known. For example, only the month and the year are 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 the month and year are 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.
An alternative solution to adding partial dates in Castor EDC would be to create several dropdown fields for day, month, and year, and mark missing data.