Title: Calling javascript function on validation
Last modified: August 21, 2016

---

# Calling javascript function on validation

 *  [G74un3](https://wordpress.org/support/users/g74un3/)
 * (@g74un3)
 * [12 years, 8 months ago](https://wordpress.org/support/topic/calling-javascript-function-on-validation/)
 * This seems like a simple problem but for some reason i haven’t been able to find
   any solution.
 * I have placed my contact form in a div tag that is just big enough to have room
   for all of the input elements. Then I want the div to expand when to make room
   for the error messenges generated when a user submits input that does not pass
   validation.
 * I have written a javascript function to get the div to expand and it works perectly.
   Then I called the function from an onclick event which I placed in a div element
   warpped around the submit button. This solution seems to work but my problem 
   is that when a user clicks the button, Contact Form 7 refreshes the page and 
   therefore the div goes back to its originale size defined by CSS.
 * So I am thinking that I need to find a way to call my javascript function after
   the page has been refreshed. Maybe along with the validation. I know of the on_sent_ok
   hook but haven’t been able to find anything similar for when a user clicks the
   button but no email is send.
 * Does anybody have any idears on how to achieve this?
 * Thank you in advance 🙂
 * [http://wordpress.org/plugins/contact-form-7/](http://wordpress.org/plugins/contact-form-7/)

The topic ‘Calling javascript function on validation’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [G74un3](https://wordpress.org/support/users/g74un3/)
 * Last activity: [12 years, 8 months ago](https://wordpress.org/support/topic/calling-javascript-function-on-validation/)
 * Status: not resolved