Skip to content

How to display character count for string fields with max setting? #3762

Answered by boutell
pasi0014 asked this question in Q&A
Discussion options

You must be logged in to vote

This is an ordinary HTML input field, utilizing the maxlength attribute, so this can't be done out of the box.

As far as displaying the number of characters so far is concerned, you could override the AposInputString component, following this guide:

https://v3.docs.apostrophecms.org/guide/custom-ui.html

And this one:

https://v3.docs.apostrophecms.org/guide/custom-schema-field-types.html#implementing-the-server-side-part

Or perhaps submit a PR for such an optional feature rather than overriding the whole component for your project.

But as for saving the data when the input is too long, I would not recommend that. Depending on the purpose of the string field it could be dangerous (i.e. too …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by pasi0014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants