is it possible to limit the characters in an input field for every form we have? I need an input field with exact 5 numbers (zip field).
I found this solution: (full code here: https://gravitywiz.com/require-minimum-character-limit-gravity-forms/)
new GW_Minimum_Characters( array(
'form_id' => 524,
'field_id' => 1,
'min_chars' => 4,
'max_chars' => 5,
'min_validation_message' => __( 'Oops! You need to enter at least %s characters.' ),
'max_validation_message' => __( 'Oops! You can only enter %s characters.')
)
);
The problem is, that we have dozens of forms and couldn't build a function for all of them ;) So we couldn't use the "form_id" and the "field_id".
Maybe there is a way to use a parameter name for the input field?
I had a similar issue where I needed to have minimum no. of characters for text fields and textarea. This setting had to be used in different forms and multiple fields therefore I could not add filters with pre-defined form ids and field ids.
What I did is that I created a new setting which was visible when editing a field and then I validated the submission. You can use the code below:
You can change the setting from Minimum Length to Exact Length and then update the validation accordingly.