File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Gravity Wiz // Gravity Forms // Conditional Readonly Fields
3+ * https://gravitywiz.com/
4+ *
5+ * This simple snippet will mark a field as readonly if a given source field has a specific value.
6+ *
7+ * Instructions:
8+ *
9+ * 1. Install this snippet with our free Code Chest plugin.
10+ * https://gravitywiz.com/gravity-forms-code-chest/
11+ */
12+ // Update "abc" to the conditional value that should be checked for in the source field.
13+ const value = "abc" ;
14+
15+ // Update "4" to the field to check for the conditional value.
16+ const $sourceField = document . getElementById ( "input_GFFORMID_1" ) ;
17+
18+ // Update "5" to the field that should be marked as readonly if the conditional value is present.
19+ const $readOnlyField = document . getElementById ( "input_GFFORMID_3" ) ;
20+
21+ $sourceField . addEventListener ( "input" , function ( ) {
22+ $readOnlyField . readOnly = $sourceField . value . toLowerCase ( ) === "abc" ;
23+ } ) ;
You can’t perform that action at this time.
0 commit comments