いろいろやり方はあると思いますが、自分ならこうするというものを書いておきます。
html
1<div>
2 <label>設問1</label>
3 <select id="form1" class="select" name="option_01">
4 <option value="" disabled selected>選択してください</option>
5 <option value="1">YES</option>
6 <option value="2">NO</option>
7 </select>
8</div>
9
10<div>
11 <label>設問2</label>
12 <select id="form2" class="select" name="option_02">
13 <option value="" disabled selected>選択してください</option>
14 <option value="1">YES</option>
15 <option value="2">NO</option>
16 </select>
17</div>
18
19<div>
20 <input type="checkbox" id="agree" value="1" disabled>
21 <label for="agree">同意する</label>
22</div>
23
24<button id="join_button" disabled>送信</button>
25
26<script>
27const form1 = document.querySelector("#form1");
28const form2 = document.querySelector("#form2");
29const agree = document.querySelector("#agree");
30const joinButton = document.querySelector("#join_button");
31
32window.addEventListener("App.Form.changed", (event) => {
33 let isFormValid = true;
34
35 isFormValid = isFormValid && form1.selectedOptions.item(0).value !== "";
36 isFormValid = isFormValid && form2.selectedOptions.item(0).value !== "";
37
38 agree.disabled = !isFormValid;
39
40 joinButton.disabled = !isFormValid;
41});
42
43form1.addEventListener("change", (event) => {
44 window.dispatchEvent(new CustomEvent("App.Form.changed"));
45});
46
47form2.addEventListener("change", (event) => {
48 window.dispatchEvent(new CustomEvent("App.Form.changed"));
49});
50</script>
追記
jQueryに置き換えたものが以下になります。
js
1<div>
2 <label>設問1</label>
3 <select id="form1" class="select" name="option_01">
4 <option value="" disabled selected>選択してください</option>
5 <option value="1">YES</option>
6 <option value="2">NO</option>
7 </select>
8</div>
9
10<div>
11 <label>設問2</label>
12 <select id="form2" class="select" name="option_02">
13 <option value="" disabled selected>選択してください</option>
14 <option value="1">YES</option>
15 <option value="2">NO</option>
16 </select>
17</div>
18
19<div>
20 <input type="checkbox" id="agree" value="1" disabled>
21 <label for="agree">同意する</label>
22</div>
23
24<button id="join_button" disabled>送信</button>
25
26<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
27
28<script>
29const $window = $(window);
30const $form1 = $("#form1");
31const $form2 = $("#form2");
32const $agree = $("#agree");
33const $joinButton = $("#join_button");
34
35$window.on("App.Form.changed", (event) => {
36 let isFormValid = true;
37
38 isFormValid = isFormValid && $form1.find("option:selected").val() !== "";
39 isFormValid = isFormValid && $form2.find("option:selected").val() !== "";
40
41 $agree.attr("disabled", !isFormValid);
42
43 $joinButton.attr("disabled", !isFormValid);
44});
45
46$form1.on("change", (event) => {
47 $window.trigger("App.Form.changed");
48});
49
50$form2.on("change", (event) => {
51 $window.trigger("App.Form.changed");
52});
53</script>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。