Passer la navigation

[Closed] Limit entries to field in a form

This support ticket is created Il y a 4 years, 6 months. 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.

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

Fuseau horaire du supporter : America/Jamaica (GMT-05:00)

Ce sujet contient 5 réponses, a 2 voix.

Dernière mise à jour par Shane Il y a 4 years, 5 months.

Assisté par: Shane.

Auteur
Publications
#2299119
Bildschirmfoto 2022-02-21 um 18.07.25.png

Hi there,

i am using the excerpt field in a form, and I would like to limit it to 200 caracters. How can I do this?

#2299239

Shane
Supporter

Les langues: Anglais (English )

Fuseau horaire: America/Jamaica (GMT-05:00)

Hi Jutta,

Can you let me know if this is a single line field or a WYSIWYG field ?

Thanks,
Shane

#2299297
Bildschirmfoto 2022-02-21 um 22.53.42.png

Hi Shane something in between 🙂 It looks like a field with several lines, but no WYSIWYG.

#2299929

Shane
Supporter

Hi Jutta,

Thank you for the clarity.

You should be able to do this by using the jQuery in below.
lien caché

Now ensure that you replace all the '$' with the text 'jQuery'

This code can be added to the JS section of your form.

Please let me know if there are any issues.
Thanks,
Shane

#2303417

Hi Shane,

thanks for your help. Unfortunately it does not work.
I have added this to the JS section:

var maxchars = 200;

jQuery('textarea').keyup(function () {
var tlength = jQuery(this).val().length;
jQuery(this).val(jQuery(this).val().substring(0, maxchars));
var tlength = jQuery(this).val().length;
remain = maxchars - parseInt(tlength);
jQuery('#remain').text(remain);
});

(where does this code know from which field I want to limit?)

Regards
Jutta

#2304861

Shane
Supporter

Hi Jutta,

The code targets the specific field with the statement "jQuery('textarea')"

However to get the actual field name I will need to look at the page that has the form. Would you mind allowing me to have access to the page so that I can have a look at the form.

Thanks,
Shane

The topic ‘[Closed] Limit entries to field in a form’ is closed to new replies.