質問編集履歴

2

JS部分も追加しました。

2019/05/14 07:30

投稿

kii.32
kii.32

スコア67

test CHANGED
File without changes
test CHANGED
@@ -169,3 +169,269 @@
169
169
  margin-left: 40px;
170
170
 
171
171
  }
172
+
173
+
174
+
175
+
176
+
177
+ <追記>
178
+
179
+
180
+
181
+ 下記のような形で、チェックボックスを作成しました。
182
+
183
+ このチェックボックスがチェックされていないときはdisabledをボタン(id:buttonx) につけて
184
+
185
+ チェックされている場合はdisabledを外すということをしたいのですが、うまくいきません。
186
+
187
+
188
+
189
+
190
+
191
+ 【コンタクトフォーム 7】
192
+
193
+ <div class="item">
194
+
195
+ <label class="label">同意事項</label>
196
+
197
+
198
+
199
+ <label class="c-checkbox">
200
+
201
+
202
+
203
+ <input type="checkbox" name="checkbox01[]" class="checkbox01-input" id="check"></input>
204
+
205
+ <span class="checkbox01-parts">プライバシーポリシーに同意</span>
206
+
207
+ <a href="https://yorozutokei.co.jp/privacypolicy/">プライバシーポリシーはこちら</a>
208
+
209
+ </label>
210
+
211
+ </div>
212
+
213
+
214
+
215
+ <div class="btn-area">
216
+
217
+ [response]
218
+
219
+ [submit class:input id:buttonx]
220
+
221
+ </div>
222
+
223
+
224
+
225
+ </form>
226
+
227
+
228
+
229
+ 【CSS】
230
+
231
+ .checkbox01-input{
232
+
233
+ display: none;
234
+
235
+ }
236
+
237
+ .checkbox01-parts{
238
+
239
+ padding-left: 20px;
240
+
241
+ position:relative;
242
+
243
+ margin-right: 20px;
244
+
245
+ }
246
+
247
+ .checkbox01-parts::before{
248
+
249
+ content: "";
250
+
251
+ display: block;
252
+
253
+ position: absolute;
254
+
255
+ top: -5px;
256
+
257
+ left: -15px;
258
+
259
+ width: 25px;
260
+
261
+ height: 25px;
262
+
263
+ border: 1px solid #C4BCB4;
264
+
265
+ border-radius: 2px;
266
+
267
+ }
268
+
269
+
270
+
271
+ .checkbox01-parts::after{
272
+
273
+ content: "";
274
+
275
+ display: block;
276
+
277
+ position: absolute;
278
+
279
+ top: 0px;
280
+
281
+ left: -5px;
282
+
283
+ width: 7px;
284
+
285
+ height: 14px;
286
+
287
+ transform: rotate(40deg);
288
+
289
+ border-bottom: 3px solid #C4BCB4;
290
+
291
+ border-right: 3px solid #C4BCB4;
292
+
293
+ border-radius:2px;
294
+
295
+ }
296
+
297
+
298
+
299
+ .checkbox01-input:checked + .checkbox01-parts::after{
300
+
301
+ content: "";
302
+
303
+ display: block;
304
+
305
+ position: absolute;
306
+
307
+ top: 0px;
308
+
309
+ left: -5px;
310
+
311
+ width: 7px;
312
+
313
+ height: 14px;
314
+
315
+ transform: rotate(40deg);
316
+
317
+ border-bottom: 3px solid #fff;
318
+
319
+ border-right: 3px solid #fff;
320
+
321
+ border-radius:2px;
322
+
323
+ }
324
+
325
+
326
+
327
+ .checkbox01-input:checked + .checkbox01-parts::before{
328
+
329
+ background-color:#3C2207;
330
+
331
+ }
332
+
333
+
334
+
335
+
336
+
337
+ .main .inner form .checkbox .wpcf7-form-control:checked + .check:after {
338
+
339
+ content: "";
340
+
341
+ display: block;
342
+
343
+ position: absolute;
344
+
345
+ top: -5px;
346
+
347
+ left: -10px;
348
+
349
+ width: 25px;
350
+
351
+ height: 25px;
352
+
353
+ background: #3C2207;
354
+
355
+  border-radius: 5px;
356
+
357
+ }
358
+
359
+
360
+
361
+ .main .inner form .checkbox .check {
362
+
363
+ padding-left: 20px;
364
+
365
+ position: relative;
366
+
367
+ margin-right: 20px;
368
+
369
+ }
370
+
371
+
372
+
373
+ .main .inner form .checkbox .check:before {
374
+
375
+ content: "";
376
+
377
+ display: block;
378
+
379
+ position: absolute;
380
+
381
+ top: -5px;
382
+
383
+ left: -10px;
384
+
385
+ width: 25px;
386
+
387
+ height: 25px;
388
+
389
+ border: 1px solid #999;
390
+
391
+ border-radius: 5px;
392
+
393
+ }
394
+
395
+
396
+
397
+ .main .inner form .c-checkbox a {
398
+
399
+ font-size: 13px;
400
+
401
+ color: #0081d6;
402
+
403
+ margin-left: 40px;
404
+
405
+ }
406
+
407
+
408
+
409
+ 【JS】
410
+
411
+ $('.checkbox01-input').change(function () {
412
+
413
+ // チェックが入っていたら有効化
414
+
415
+ if ($(this).is(':checked')) {
416
+
417
+ // ボタンを有効化
418
+
419
+ $('#buttonx').prop("disabled", false);
420
+
421
+ } else {
422
+
423
+ // ボタンを無効化
424
+
425
+ $('#buttonx').prop("disabled", true);
426
+
427
+ }
428
+
429
+ });
430
+
431
+
432
+
433
+
434
+
435
+ この記載だとチェックが入っていてもいなくても、送信ができてしまいます、、、
436
+
437
+ どなたかご教授いただけないでしょうか。

1

チェックボックスの画像を追加しました

2019/05/14 07:30

投稿

kii.32
kii.32

スコア67

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,9 @@
1
+ ![イメージ説明](99c50ce009559f33c64709dcd1f95851.png)
2
+
3
+ ![イメージ説明](9e42e79154d1118ce4c30c5a748ba308.png)
4
+
5
+
6
+
1
7
  下記のサイトを参考にチェックボックスをカスタムしているのですが、:checkedの反応がうまくいきません。
2
8
 
3
9
  http://takeshishomepage.com/blog/2018/05/14/css%E3%81%A7checkbox%E3%82%92%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%9E%E3%82%A4%E3%82%BA%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95/