-
AuthorPosts
-
September 24, 2024 at 8:11 am #1467714
Hi,
i’m using contact form 7 and trying to change the colour of the * (for requiered fields to red.This is what i got in the form:
<div class="form-row"> <div class="column-half"> [text* first-name placeholder "First name *"]</div> <div class="column-half"> [text* last-name placeholder "Last name *"]</div> <div class="form-row"> <div class="column-full"> [email* your-email placeholder "Email"]</div> </div> <div class="form-row"> <div class="column-full"> [textarea* your-message placeholder "Your message *"]</div> </div> <div class="form-row"> <div class="column-full">[submit "Send"]</div> </div>
kind regards
JakSeptember 24, 2024 at 10:56 am #1467735Hey Jak73,
It’s not possible to style the star only, since it’s added with the rest of the text. If you refer to the plugin documenations, then maybe there is a default way of adding a required character? Please note that we are here to support the Enfold theme, not Contact Form 7.
Best regards,
RikardSeptember 25, 2024 at 5:20 pm #1467821as placeholder text ( inside the input field ) this is hard to get.
September 26, 2024 at 1:25 pm #1467878ok – if this is ok for you – see: https://webers-testseite.de/jak-contact/
( due to maintainance mode of my hoster – page might be not seen today )snippet for child-theme functions.php and the contakt form 7 Form code is on that page.
snippet:
(The script is necessary because CF7 does not provide a way to select whether an input field is in focus or filled.)function class_on_active_form_fields(){ ?> <script> window.addEventListener("DOMContentLoaded", function () { (function($) { $('.wpcf7-form-control').each(function() { $(this).on('focus', function() { $(this).parent().addClass('active'); }); $(this).on('blur', function() { if ($(this).val().length == 0) { $(this).parent().removeClass('active'); } }); }); })(jQuery); }); </script> <?php } add_action('wp_footer', 'class_on_active_form_fields');
the css ( with your wrapper class ):
.form-wrapper { position : relative !important; } .form-wrapper .placeholder { position: absolute; top: 5px; left: 5px; opacity: 0.5; transition: opacity 1s ease; pointer-events: none; } .form-wrapper .asterisk { color: red !important; } .wpcf7-form-control-wrap.active + .placeholder { opacity: 0 !important; }
the form in this setup:
<div class="form-wrapper">[text* first-name placeholder ""]<span class="placeholder">First name <span class="asterisk">*</span></span></div> <div class="form-wrapper">[text* last-name placeholder ""]<span class="placeholder">Last name <span class="asterisk">*</span></span></div> <div class="form-wrapper">[email* your-email placeholder " "]<span class="placeholder">E-Mail <span class="asterisk">*</span></span></div> <div class="form-wrapper">[textarea* textarea-716 placeholder " "]<span class="placeholder">Placeholder <span class="asterisk">*</span></span></div> <div class="form-wrapper">[submit "Send"]</div>
September 26, 2024 at 6:56 pm #1467891Genius, thank you!
I’ll give it a try
JakSeptember 26, 2024 at 8:18 pm #1467892 -
AuthorPosts
- You must be logged in to reply to this topic.