Dynamic text field question

i’ve got some very small dynamic text fields which i’d like to limit to 17 chars and 22 chars. The text will be populated via either a remote feed or database, etc.

i know you can limit input text fields maxChars, but is there an easy way to limit a dynamic txt box besides stripping the string down using substring method?