Custom Validation - bcgov/common-hosted-form-service GitHub Wiki

This documentation is no longer being updated. For the most up to date information please visit our techdocs

Home > CHEFS Components > Custom Components > Custom Validation


Get started

Day Component

Let's cover the custom validation for Day component When the editor opens, navigate to tab Validation and scroll down to open the section named Custom Validation. Inside the Javascript section you need to write

var val = moment(input, 'MM/DD/YYYY');
valid = true;
if (!val.isValid() || val.format('YYYY') === '0000') {
  valid = 'Please, enter the valid date';
}

Common Hosted Forms Service 2023-10-23 15-53-26

This way we validate if user enter incorrect Day for example e2, -2, +2 or leaves Year box empty