Have you ever received a generic comment or question in a form submission and wondered if there was a way to discourage this type of response? We’ve whipped up a little snippet that you can use to encourage a more descriptive comment from users submitting your forms.
View this code snippet on GitHub.How do I get started?
- This will work with even Gravity Forms v1.0 but that’s no excuse not to be running the latest version.
- Already have a license? Download Latest Gravity Forms
- Need a license? Buy Gravity Forms
- Copy and paste the snippet into your theme’s functions.php file.
- Once you have installed the snippet, you just need to configure the snippet for your Gravity form. See the usage instructions below.
Usage
View this code snippet on GitHub.Parameters
The form_id
, field_id
, and min_chars
parameters are required. Incorrect values will cause the snippet to fail silently; no error message will be displayed.
- form_id (integer) (required) The form ID of your form.
- field_id (integer) (required) The field ID of the field that you would like to enable a minimum character limit.
- min_chars (integer) (required) The minimum character limit that you would like to apply to the field.
- validation_message (string) (optional) The validation message that you would like to display to the user when the minimum character limit is not reached.
- min_validation_message (string) (optional)
The validation message that you would like to display to the user when the minimum character limit is not reached. Added to better differentiate between the
validation_message
and themax_validation_message
parameters. - max_validation_message (string) (optional) The validation message that you would like to display to the user when the maxiumum character limit is exceeded.
Can I add this to more than one field per form?
You sure can! You can add this to as many fields on as many forms as you want. Simply copy and paste the configuration code listed above and update the values for your new form and field.
If you use it and like it, let us know. We’d love to hear the different reasons how you found this code useful!