Skip to content

Commit dc763b4

Browse files
authored
gw-conditional-readonly.js: Added new snippet.
1 parent 07c432e commit dc763b4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
});

0 commit comments

Comments
 (0)