Family Encyclopedia >> Electronics

How to use Javascript popups to display gravity form error messages

Gravity Forms is potentially the most beginner-friendly contact form out there. The best part of Gravity Forms is its customization. It allows even advanced users to make changes to its functionality. In a recent article, we showed you how you could add placeholder text to gravity forms. In this article, we'll show you how you can customize the way error messages are displayed.

To do this, open your functions.php file and paste the following code:

 add_filter ('gform_validation_message', 'sw_gf_validation_message', 10, 2); function sw_gf_validation_message ($ validation_message) add_action ('wp_footer', 'sw_gf_js_error'); function sw_gf_js_error () ?> alert ("¡Vaya, debes haber olvidado algo ... los campos marcados con un * son obligatorios!");  

You can change the error message by modifying what is inside the alert() function. Now whenever someone forgets to complete something, the error message will be displayed in the javascript popups instead of on top of your gravity forms.

Credits:Brad Williams