@replace {{class}}
<?php
// Checks whether form inputs are filled and adds a targetable class if they have value
add_action( 'wp_footer', function () { ?>
<script type="text/javascript">
jQuery(document).ready( function() {
function checkFilledInputs() {
jQuery('textarea,input').each( function() { toggleFilledInputs(this); });
jQuery('textarea,input').change( function() { toggleFilledInputs(this); });
}
function toggleFilledInputs(e) {
if ( jQuery(e).val().trim().length > 0 ) {
jQuery(e).addClass('{{class}}');
} else {
jQuery(e).removeClass('{{class}}');
}
}
jQuery(document).bind('gform_post_render', function() { checkFilledInputs(); });
checkFilledInputs();
});
</script>
<?php } );