wordpresscontact-form-7

disable one option from the multiple options of the select


I created a contact form with the plugin contact form 7. My problem is i want to disable one option from the multiple options of the select. This is my code :

[select evenement class:form-control  "first-option" "second-option" ....]

Please tell me how can i fix this problem.


Solution

  • You'll need to add some custom javascript code to do this, you can add it right below your cf7 tag in your form,

    [select evenement class:form-control  "first-option" "second-option" ....]
    <script type="text/javascript">
    (function( $ ) {
      'use strict';
      $(document).ready( function(){
        var $select =  $('.wpcf7-form-control-wrap.evenement select', 'form.wpcf7');
        $('option[value="first-option"]', $select).attr('disabled',true);
      });
    })(jQuery)
    </script>`