79191644

Date: 2024-11-15 08:56:01
Score: 3.5
Natty:
Report link

Having the same problem, I want to share my solution using Vanilla Javascript, so no need to use jQuery.

In Contact Form 7 having a select field like this:

[select* my-select-field class:form-control first_as_label "Please Select Option" "Option 1" "Option 2" "Option 3 is not selectable"]

Assumng the CF7 form has class .wpcf7-form

<script type="text/javascript"> document.addEventListener('DOMContentLoaded', function() { var selectElement = document.querySelector('.wpcf7-form select[name="my-select-field"]'); var lastOption = selectElement.querySelector('option[value="Option 3 is not selectable"]'); lastOption.disabled = true; }); </script>

Paste javascript code at the bottom of your contact form 7 after submit button. Enjoy.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): Having the same problem
  • Low reputation (1):
Posted by: vvave vvave