Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created June 16, 2016 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/357c22f5afa9d0bee54b61939cc69276 to your computer and use it in GitHub Desktop.
Save tripflex/357c22f5afa9d0bee54b61939cc69276 to your computer and use it in GitHub Desktop.
Set a field as Read Only using jQuery
<?php
add_action( 'submit_job_form_start', 'my_custom_jquery_set_field_readonly' );
function my_custom_jquery_set_field_readonly(){
/**
* Replace FIELD_META_KEY with the meta key of the field you want to set as readonly.
* If you want to set it as disabled instead, just change 'readonly' to 'disabled'
*/
echo "<script>jQuery(function($){ $('#FIELD_META_KEY').prop('readonly', true); });</script>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment