I have used Wordpress plugin Contact Form 7 to my form. How can I adjust error class to input tag.
Now I have
<div class="row">
<div class="group">
[email* email placeholder "e-mail *"]
</div>
</div>
<div class="_row">
<div class="group group--checkbox">
[acceptance accept1 id:accept1]<label for="accept1">Accept terms *</label>
</div>
</div>
[submit class:ipb-btn class:ipb-btn--primary-solid "Submit"]
This wrapp my inputs into tag so I usede filter:
add_filter('wpcf7_form_elements', function($content) {
$content = preg_replace('/<(span).*?class="\s*(?:.*\s)?wpcf7-form-control-wrap(?:\s[^"]+)?\s*"[^\>]*>(.*)<\/\1>/i', '\2', $content);
return $content;
});
My contact Form now Render HTML like this:
<div class="row">
<div class="group">
<input type="email" name="email" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-email wpcf7-validates-as-required wpcf7-validates-as-email" aria-required="true" aria-invalid="false" placeholder="e-mail *">
</div>
</div>
<div class="row">
<div class="group group--checkbox">
<input type="checkbox" name="accept1" value="1" class="wpcf7-form-control wpcf7-acceptance " id="accept1" aria-invalid="false"><label for="accept1">Accept terms *</label>
</div>
</div>
<input type="submit" value="Submit" class="wpcf7-form-control wpcf7-submit"><span class="ajax-loader"></span>
<div class="wpcf7-response-output wpcf7-display-none"></div>
But how Can I add invalid class to my inputs to regocnize it's invalid?
I use filter wpcf7_form_elements to remove span - I have custom checkbox field (:before element) and I have css input[type="checkbox"]:checked + label {my-css}
When I have span elements it render like this:
<span>
<input type="checkbox">
</span>
<label>test</label>
So I can't use css input + label {}
Any idea what can I do?
Aucun commentaire:
Enregistrer un commentaire