Skip to Main Content

Comments

To initialize the plugin, use a DA on 'Page Load' and select 'LIB4X - Validation'. The validation plugin for this page is configured with Instant Validation.

The Task Code should start with 'T' and have minimum length 6 - in case you enter something else, immediately you see the validation feedback. The Instant Validation will show if an item has a validation error and the item is 'dirty'. Dirty means the user has applied a change. An item remains Dirty in case the user undoes the change, which makes this Dirty flag different from the isChanged flag. So, though the Task Code is required, if you tab out of the field without any value, no validation feedback will come as yet.

The Start Date should be on or after the End date. A Dynamic Action on 'Validate Item' has been defined with JavaScript Action: if (this.data.formData.P8_END_DATE.setHours(0,0,0,0) < this.data.formData.P8_START_DATE.setHours(0,0,0,0)) { this.data.valid = false; this.data.validationMessage = 'Have an end date on or after the start date.' }

this.data.formData will have the native values of all page items. So a Date Item will come as a native JavaScript Date object and not as a text value.

The validation outcome is by default valid - use this.data.valid = false; as to turn it invalid and set a validation message (or rely on the 'data-valid-message' attribute).

Team and User can not be both empty. A Dynamic Action on 'Validate Page' has been defined with JavaScript Action: if (!this.data.formData.P8_TEAM && !this.data.formData.P8_USER) { this.data.valid = false; this.data.validationMessage = 'Give a team or a user or both.' }

Any custom validation will only be executed in case the declarative validation constraints have passed. Custom validation can be defined for all Item Types, and for both IG Column Items as well as regular Items. For an IG, also a Row Validation can be defined, similar to the Page Validation.

The this.data object in the event handler will have extended context like the formData above. For IG, it will have an activeRow object with native values of all column items. For IG, it will also give direct handles to the underlying model and gridView.