Press "Enter" to skip to content

Web Dev Tid Bit (WDTB): Adding Custom Classes to Gravity Forms Confirmation and Validation Messages

 

Gravity Forms has filters to allow you to customize the validation and confirmation messages of your forms. If you are using a Bootstrap framework and want to style the messages like alerts, you can use these pieces of code to accomplish that.

Validation Error:

This takes the default validation code and adds the alert and alert-danger class to them via the “gform_validation_message” filter. You could also change up the message itself and be selective on which form you want it to be changed for by putting in logic to determine what $form[‘id’] you are working with.

Confirmation Message:

Similar to the validation error filter above, this wraps the default confirmation in a div with the alert and alert-success Bootstrap classes.