Read Only Textarea

Use this in your functions.php file to change a textarea to readonly.

// update ‘2’ to the ID of your form
add_filter(‘gform_pre_render_2’, ‘add_readonly_script’);
function add_readonly_script($form){
    ?>

    <script type=”text/javascript”>
        jQuery(document).ready(function(){
            jQuery(“li.gf_readonly textarea”).attr(“readonly”,”readonly”);
        });
    </script>

    <?php
    return $form;
}

Then add  the .gf_readonly class to your textarea in the backend of gravity forms.

Leave a Reply