Last active
June 25, 2022 21:52
-
-
Save macariojames/b671ae3cb01f6ea3ac9d1ec0a519b8d3 to your computer and use it in GitHub Desktop.
Disabling Form Select Option based on value (Gravity Form)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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
Where do I place it?