Oracle APEX - Custom Client-Side Validation Plugin

#lib4x

APEX offers some declarative settings for client-side validation like 'Required', 'Minimum Value'/'Maximum Value' and the item subtypes. And for few item types, you can use HTML5 validation attributes like ‘pattern’. In case you need additional, more advanced client-side validation, there is no explicit support.

So this plugin offers a help here by offering 'Validate Item', 'Validate Page' and 'Validate IG Row' events which can be used in DA's as to define custom validation logic in a JavaScript action. In the event handler, you can use this.data as input for your constraint logic. Set this.data.valid (boolean) as the validation outcome, and set this.data.validationMessage in case of an error. The plugin can be configured with 'Instant Validation'.

image

Custom validation can be defined for all Item Types, and for both IG Column Items as well as regular Items.

The 'Validate Page' and 'Validate IG Row' events do support validation logic on the page/row level.

To initialize the plugin, use a DA on 'Page Load' and select 'LIB4X - Validation'. Select if you want to use 'Instant 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.

See demo and example: demo page

Find the plugin in this github repository.

Needless to say, your server-side validations remain important as they only give real protection. Client-side validations are on top for instant feedback without round-trips to the server.