[Plugin: Contact Form 7] Adding Classes to Invalid Labels/Inputs
-
Has anyone found a proper way to add error classes to the fields and corresponding labels that did not pass validation when using AJAX form submission?
The only way I have found to do this is to add the following code to the $.fn.wpcf7NotValidTip() function in scripts.js:
into.find(':input').addClass('wpcf7-not-valid-field'); $("label[for='" + into.find(':input').attr('id') + "']").addClass('wpcf7-not-valid-label');
And of course logic for removing the additional classes on the .focus() event:
into.find(':input').removeClass('wpcf7-not-valid-field'); $("label[for='" + into.find(':input').attr('id') + "']").removeClass('wpcf7-not-valid-label');
Obviously, this is not an ideal solution. I have not been able to find anything on these forums, nor via many Google searches.
If the author sees this, can this (or something similar) be added as an enhancement? It is very useful to actually style the invalid inputs and labels, rather than just displaying an error message beside them.
- The topic ‘[Plugin: Contact Form 7] Adding Classes to Invalid Labels/Inputs’ is closed to new replies.