Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript:表单验证-如果未选中复选框,如何要求填写文本区域_Javascript_Validation - Fatal编程技术网

Javascript:表单验证-如果未选中复选框,如何要求填写文本区域

Javascript:表单验证-如果未选中复选框,如何要求填写文本区域,javascript,validation,Javascript,Validation,我对javascript还是相当陌生,还没有能够独自解决这个问题。希望有人能帮助我 想要:如果用户不选中所有复选框,则必须在文本区域框中提供信息。需要在JS中添加验证 代码如下: HTML <label class="form-check-label"> <input class="form-check-input" type="checkbox" value="orange"> Or

我对javascript还是相当陌生,还没有能够独自解决这个问题。希望有人能帮助我

想要:如果用户不选中所有复选框,则必须在文本区域框中提供信息。需要在JS中添加验证

代码如下:

HTML

<label class="form-check-label">
  <input class="form-check-input" type="checkbox" value="orange">
  Orange
</label>
<label class="form-check-label">
  <input class="form-check-input" type="checkbox" value="apple">
  Apple
</label>
<label class="form-check-label">
  <input class="form-check-input" type="checkbox" value="banana">
  Banana
</label>

<small class="form-text text-muted">If no choice is made, explain why below.      
</small>

<legend for="other-information">Other information</legend>
<label>Explain here.</label>
<textarea class="form-control" type="text" id="other-info-text-area" rows="3"></textarea>
谢谢大家!

function validateForm() {
const form = document.forms[info-form];
//insert validation here.