回答編集履歴
1
追記
test
CHANGED
@@ -105,3 +105,123 @@
|
|
105
105
|
</script>
|
106
106
|
|
107
107
|
```
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
## 追記
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
jQueryに置き換えたものが以下になります。
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
``` js
|
120
|
+
|
121
|
+
<div>
|
122
|
+
|
123
|
+
<label>設問1</label>
|
124
|
+
|
125
|
+
<select id="form1" class="select" name="option_01">
|
126
|
+
|
127
|
+
<option value="" disabled selected>選択してください</option>
|
128
|
+
|
129
|
+
<option value="1">YES</option>
|
130
|
+
|
131
|
+
<option value="2">NO</option>
|
132
|
+
|
133
|
+
</select>
|
134
|
+
|
135
|
+
</div>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
<div>
|
140
|
+
|
141
|
+
<label>設問2</label>
|
142
|
+
|
143
|
+
<select id="form2" class="select" name="option_02">
|
144
|
+
|
145
|
+
<option value="" disabled selected>選択してください</option>
|
146
|
+
|
147
|
+
<option value="1">YES</option>
|
148
|
+
|
149
|
+
<option value="2">NO</option>
|
150
|
+
|
151
|
+
</select>
|
152
|
+
|
153
|
+
</div>
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
<div>
|
158
|
+
|
159
|
+
<input type="checkbox" id="agree" value="1" disabled>
|
160
|
+
|
161
|
+
<label for="agree">同意する</label>
|
162
|
+
|
163
|
+
</div>
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
<button id="join_button" disabled>送信</button>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<script>
|
176
|
+
|
177
|
+
const $window = $(window);
|
178
|
+
|
179
|
+
const $form1 = $("#form1");
|
180
|
+
|
181
|
+
const $form2 = $("#form2");
|
182
|
+
|
183
|
+
const $agree = $("#agree");
|
184
|
+
|
185
|
+
const $joinButton = $("#join_button");
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
$window.on("App.Form.changed", (event) => {
|
190
|
+
|
191
|
+
let isFormValid = true;
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
isFormValid = isFormValid && $form1.find("option:selected").val() !== "";
|
196
|
+
|
197
|
+
isFormValid = isFormValid && $form2.find("option:selected").val() !== "";
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
$agree.attr("disabled", !isFormValid);
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
$joinButton.attr("disabled", !isFormValid);
|
206
|
+
|
207
|
+
});
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
$form1.on("change", (event) => {
|
212
|
+
|
213
|
+
$window.trigger("App.Form.changed");
|
214
|
+
|
215
|
+
});
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
$form2.on("change", (event) => {
|
220
|
+
|
221
|
+
$window.trigger("App.Form.changed");
|
222
|
+
|
223
|
+
});
|
224
|
+
|
225
|
+
</script>
|
226
|
+
|
227
|
+
```
|