Problem:
I am trying to set the maximum number of characters for a generic text field on a CRED user form I would like to know if there is a way to achieve this without using JavaScript, possibly by using a filter or extending the PHP class responsible for the generic text field.
Solution:
The best way to accomplish this is by adding JavaScript code to the JS Editor of your form to include the desired attribute.
document.addEventListener('DOMContentLoaded', function() { var textField = document.querySelector('input[name="job_title"]'); if (textField) { textField.setAttribute('maxlength', '50'); } });
Replace "job_title" with the field name that you have.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_generic_field
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.
This topic contains 2 replies, has 2 voices.
Last updated by 1 year, 7 months ago.
Assisted by: Christopher Amirian.