Contact Form 7 validation issues on select2

Contact Form 7 validation issues on select2

Having the following code, got from the developer but she is unable to fix the select2 issue because she does not knows it.

<script type="text/javascript"> jQuery(document).on('blur', 'input.wpcf7-validates-as-required,.select2-container .select2-selection--single', function(event){ empty = jQuery(this).val(); alert(empty); if(empty == '') { jQuery(this).addClass('wpcf7-not-valid'); } else { jQuery(this).removeClass('wpcf7-not-valid'); } }); </script>

How can i add a select2 check in this check, i want to add in the way that if the selectbox exists and defined as select2, only then it should check for the select2 validation else validates normally with input fields.

Thanks

For me, i tried the css of the class but somehow it is not working, i can provide a screenshot of what i tried here

http://prntscr.com/huug7x