Skip to content

Instantly share code, notes, and snippets.

@macariojames
Last active June 25, 2022 21:52
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 macariojames/b671ae3cb01f6ea3ac9d1ec0a519b8d3 to your computer and use it in GitHub Desktop.
Save macariojames/b671ae3cb01f6ea3ac9d1ec0a519b8d3 to your computer and use it in GitHub Desktop.
Disabling Form Select Option based on value (Gravity Form)
// This was specifically for Gravity Form i wanted to disable options based on a null value.
// In the dropdown I had, some values were used as headers so people would know the type of
// item they were selecting -- in this case the dropdown was for liquor/wine selection
// Before to put the "true" part after disabled rather than leaving it blank
// or it won't work in any browser but Chrome (Mac).
// gForm disable select options with null or '|0' value
$('.gform_body select option[value="null|0"]').attr("disabled","true");
// For Safari if the above doesn't work use this
// gForm disable select options with null or '|0' value
$('.gform_body select option[value="null|0"]').attr("disabled","disabled").prop("disabled", true);
@yeasirjamal
Copy link

Where do I place it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment