Skip Navigation

[Resolved] Can i limit characters count for my single-line text field in CRED forms ?

This thread is resolved. Here is a description of the problem and solution.

Problem:
Can i limit characters count for my single-line text field in CRED forms?

Solution:
You should add custom javascript code to your CRED form's JS box and it should work.

For example:

jQuery(document).ready(function ($) {
  $('name^=wpcf-FIELD-NAME]').attr('maxlength',20);
});

Where:
- Replace FIELD-NAME with above code with your actual field name and set the maxlength limit accordingly. Currently its as as 20.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/can-i-limit-characters-count-for-my-single-line-text-field-in-cred-forms/#post-908303

Relevant Documentation:

This support ticket is created 6 years, 6 months ago. 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
- 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)

This topic contains 2 replies, has 3 voices.

Last updated by olliM-3 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#907828

Eso

I have tried that but it didnt work...

https://toolset.com/forums/topic/can-i-limit-characters-entered-into-a-custom-single-line-text-field/

Then I've tried that:

https://toolset.com/forums/topic/limit-character-count-om-a-cred-field/

But didnt work either.

The two of them are very old tickets.

So I wonder if there's a new solution for single line field character limitations in CRED....

Thanks for your help in advance.

#908303

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - following code you should add to your CRED form's JS box and it should work.

jQuery(document).ready(function ($) {
  $('name^=wpcf-FIELD-NAME]').attr('maxlength',20);
});

Where:
- Replace FIELD-NAME with above code with your actual field name and set the maxlength limit accordingly. Currently its as as 20.

If your issue still persists, please feel free to contact me with problem URL and access I would be happy to fix this issue on your install on your behalf.

#1177674

Hi,

The code that Minesh posted is correct but there is a small error.
There should be [ before the name^=wpcf- part.

The correct code is:

jQuery(document).ready(function ($) {
  $('[name^=wpcf-kapuaja-header-text]').attr('maxlength',160);
});

Came here to clarify because people will find this solution with Google and think it is not working.