Skip to content

Instantly share code, notes, and snippets.

@wpmonks
Created June 7, 2019 11:10
Show Gist options
  • Save wpmonks/77ee8c8de3be528e47fc35c536ee159c to your computer and use it in GitHub Desktop.
Save wpmonks/77ee8c8de3be528e47fc35c536ee159c to your computer and use it in GitHub Desktop.
Disable a form field to stop users input data.
/**
* Disable form fields to make read-only
* To apply, add CSS class 'wpmonks-readonly' (no quotes) to field in form builder
*
*/
function wpmonks_disable_field() {
?>
<script type="text/javascript">
jQuery(function($) {
$(".wpmonks-readonly input").attr("readonly", true);
});
</script>
<?php
}
add_action( 'wpforms_wp_footer', 'wpmonks_disable_field' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment