{"id":296,"date":"2015-10-14T13:16:20","date_gmt":"2015-10-14T13:16:20","guid":{"rendered":"http:\/\/www.effectualmedia.com\/blog\/?p=296"},"modified":"2017-08-21T09:37:45","modified_gmt":"2017-08-21T09:37:45","slug":"contact-form-7-how-to-hide-validation-errors-on-hover","status":"publish","type":"post","link":"http:\/\/www.effectualmedia.com\/blog\/contact-form-7-how-to-hide-validation-errors-on-hover\/","title":{"rendered":"Contact Form 7 | How to Hide Validation Errors on Hover"},"content":{"rendered":"<p style=\"text-align: center;\"><img class=\"aligncenter\" src=\"http:\/\/www.effectualmedia.com\/blog\/wp-content\/uploads\/2017\/08\/form-validation.jpg\" alt=\"Contact Form 7 Validation\"><\/p>\n<p>Contact form 7 by default handles validation quite well; the form displays validation error messages (e.g., on leaving required fields blanks and submit wrong values on email etc&#8230;)<\/p>\n<p>But problem is validation error don\u2019t disappear even after you filled all required fields with corrects values. Even you filled field with correct information, validation boxes messages stay in place and create confusion for user. Ideally when user click back on field then the validation message should disappears.<\/p>\n<p><strong>This post describes<\/strong> how you hide the validation error messages that Contact Form 7 produces.<!--more--><\/p>\n<h3>Option 1: jQuery Fix:<\/h3>\n<p>Place following code before closing of head tag.<\/p>\n<p><code lang=\"javascript\"><\/p>\n<p style=\" font-weight: 800; \">\njQuery(document).ready(function($) {<br \/>\n\t\/\/ clear cf7 error msg on mouseover<br \/>\n\t$(\".wpcf7-form-control-wrap\").mouseover(function(){<br \/>\n\t\t$obj = $(\"span.wpcf7-not-valid-tip\",this);<br \/>\n    \t        $obj.css('display','none');<br \/>\n\t});<br \/>\n});\n<\/p>\n<p><\/code><\/p>\n<p>Other alternative option is to change cform7&#8217;s core file code, which one should explore if Option 1 don&#8217;t work with your theme. Not the best solution, but definitely acceptable.<\/p>\n<h3>Option 2: Edit Scripts.js:<\/h3>\n<p>Navigate to \/plugins\/contact-form-7\/includes\/js\/script.js, find <strong>$.fn.wpcf7NotValidTip<\/strong> function and replace entire code of that function with following code.<\/p>\n<p><code lang=\"javascript\"><\/p>\n<p style=\" font-weight: 800; \"><code lang=\"javascript\"><br \/>\n$.fn.wpcf7NotValidTip = function(message) {<br \/>\nreturn this.each(function() {<br \/>\nvar $into = $(this);<\/code><\/p>\n<p style=\"font-weight: 800;\">$into.find(\u2018span.wpcf7-not-valid-tip\u2019).remove();<br \/>\n$into.append(\u2018<span class=\"wpcf7-not-valid-tip\">\u2018 + message + \u2018<\/span>\u2018);<\/p>\n<p style=\"\n    font-weight: 800;\n\">if ($into.is(\u2018.use-floating-validation-tip *\u2019)) {<br \/>\n$(\u2018.wpcf7-not-valid-tip\u2019, $into).mouseover(function() {<br \/>\n$(this).wpcf7FadeOut();<br \/>\n});<\/p>\n<p style=\"\n    font-weight: 800;\n\">$(\u2018:input\u2019, $into).focus(function() {<br \/>\n$(\u2018.wpcf7-not-valid-tip\u2019, $into).not(\u2018:hidden\u2019).wpcf7FadeOut();<br \/>\n});<br \/>\n}<br \/>\n});<br \/>\n};\n<\/p>\n<p><\/code><br \/>\nThis jQuery fix makes sure the CF7 validation error disappears when it\u2019s getting a click of the user.<\/p>\n<p>You need to create documentation for these code file changes; so you can change code in future if plug-in developer update code in future upgrades.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Contact form 7 by default handles validation quite well; the form displays validation error messages (e.g., on leaving required fields blanks and submit wrong values on email etc&#8230;) But problem is validation error don\u2019t disappear even after you filled all &hellip; <\/p>\n<p><strong><a href=\"http:\/\/www.effectualmedia.com\/blog\/contact-form-7-how-to-hide-validation-errors-on-hover\/\">Read More<\/a><\/strong><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,14],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/posts\/296"}],"collection":[{"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/comments?post=296"}],"version-history":[{"count":37,"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/posts\/296\/revisions"}],"predecessor-version":[{"id":1131,"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/posts\/296\/revisions\/1131"}],"wp:attachment":[{"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/media?parent=296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/categories?post=296"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.effectualmedia.com\/blog\/wp-json\/wp\/v2\/tags?post=296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}