Skip Navigation

[Gelöst] Limit number of characters or words in Single Line field

This support ticket is created vor 7 Jahren, 6 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 5 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 7 Jahren, 6 Monaten.

Assistiert von: Minesh.

Author
Artikel
#516303

I am trying to: limit the number of characters or words that admins can input into a specific single line field. The field is called 'okpa-member-description'

I visited this URL and all the suggestions Beda linked to in the topic :
https://toolset.com/forums/topic/multi-line-field-maximum-words-or-characters/

I think this can be done by adding code to my functions.php file, and also adding some js. In my theme I have a js folder, so I would probably add a new js file in their.

Not sure of how to pull it off. I especially tried using the method in this post, but couldn't figure it out:
https://toolset.com/forums/topic/can-i-limit-characters-entered-into-a-custom-single-line-text-field/

Any help will be appreciated.

#516510

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Could you please tell me where you are trying to limit the character limit for field - is it in backend or frontend?

if its in frontend - Could you please share the problem URL - also is 'okpa-member-description' field type you set for this field?

#516560

Hi Minesh

Sorry for the lack of clarity.

I am setting up the site so that when the site owner, probably with Editor permissions, can input on a Single Line field up to a maximum of 100 characters. To me that is the front end in that the Editor is the front end user.

As far as editing the files to implement the change, I have been working in the back end, editing files via cPanel file editor.

This is a Post Field.
The field-type is and Single Line field.
The field-slug is: 'okpa-member-description'

#516580

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Please try to use the following solution if you are using field inside the CRED form:
=> https://toolset.com/forums/topic/limit-characters-in-multiple-custom-fields-in-a-cred-form/#post-349241

OR

You may try to add max_length attribute using jQuery. For example:

jQuery(document).ready(function () {
       jQuery("input[name='wpcf-okpa-member-description']").attr("maxlength", 4);
});

Please check if "wpcf-" prefix is added to your field name "okpa-member-description".

#516590

Thanks Minesh. I will try this. But I'm not using it in a CRED form. I'm using it in a Custom Post Type. Will give it a try.

#516595

Minesh
Supporter

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Ok fine - thank you. Most probably the second example with maxlength attribute will work for you.