Input Types with custom validation script and error messages

Probably a “big list” feature request:

Following the thread discussing a feature for “Maximum length of TextLine or TextArea” Maximum length of TextLine or TextArea

…it makes me think that it would be great if the built-in Input Types had support for writing a script (JavaScript?) that fired on each onchange() event of the input field, having the value as input, and returning an object with boolean errorState and string errorMsg

With such a feature, one could then write a script that either did a simple regexp match, or something more complex if you wanted to. You could for instance create different types of descriptive and helpful error messages that depended on the type of regex match you got, giving big bonus points to user-friendliness.

I’m not sure if there is an overlap between the help text and custom error messages, but this correlation should probably be assessed.

Returning a function that could do stuff in the form would be nice, but is probably a case better suited for writing completely new custom input types.

Of course one could implement custom validation and error messages if one extends Enonic XP with custom input types, but this feature request deals with the built-in input types, which would app developers to make them more user-friendly if they had this feature.

1 Like

@bhj: I think this relates a bit to the feature request I registered in June: Validation in content types

Custom validation, error messages and possibly conditional fields (if -this- is selected, show -that- field) would be great, and from the response I got, it seems this might be implemented in a future version.

2 Likes

Hi… Our plan is that input Types will be pluggable - this way you can create your own magic validation as you wish. Also, we’re adding regular expressions to textline.

For the more advanced cases, we’ll look into this in the future when re-visiting the displayNameScript - most likely this will be a pure admin UI script to make the forms more dynamic.

2 Likes