The following JavaScript code listens to date field changes and checks the difference between today's date and the date field in months. A hidden checkbox is set to allow control of other field visibility.
// Listen to date field changes
window.formyoula.form_fields['Date Field'].on('all', function(options) {
// Gte date field value
var date_field_value = this.get('value');
// Check if date field is older then 6 months
if ( moment().diff(moment(date_field_value), 'months') > 6 ) {
// Set hidden checbox to true
window.formyoula.form_fields['Date Field Validation Checkbox'].set({ value: true });
} else {
// Set hidden checbox to false
window.formyoula.form_fields['Date Field Validation Checkbox'].set({ value: false });
}
});
Example template for import - https://app.formyoula.com/templates/import
Date Field Controlling Other Field Visibility.json4.0KB
For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂