Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.