File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1313const value = "abc" ;
1414
1515// Update "4" to the field to check for the conditional value.
16- const $sourceField = document . getElementById ( "input_GFFORMID_1 " ) ;
16+ const $sourceField = document . getElementById ( "input_GFFORMID_4 " ) ;
1717
1818// 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 " ) ;
19+ const $readOnlyField = document . getElementById ( "input_GFFORMID_5 " ) ;
2020
21+ // Evaluate once when the form is rendered.
22+ setFieldAsReadonlyConditionally ( ) ;
23+
24+ // Evaluate again each time our source field receives input.
2125$sourceField . addEventListener ( "input" , function ( ) {
22- $readOnlyField . readOnly = $sourceField . value . toLowerCase ( ) === "abc" ;
26+ setFieldAsReadonlyConditionally ( ) ;
2327} ) ;
28+
29+ function setFieldAsReadonlyConditionally ( ) {
30+ $readOnlyField . readOnly = $sourceField . value . toLowerCase ( ) === value ;
31+ }
You can’t perform that action at this time.
0 commit comments