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