我正在使用来自 formvalidation.io 的 jquery 表单验证插件,我正在尝试实现条件,就好像选中了复选框然后使子表单字段成为必需的,否则不验证表单。我如何使用 formvalidation 插件制定规则...
<script>
function showSchoolInfoFields(chk) {
document.getElementById("div1").style.display = chk.checked ? "block" : "none";
}
</script>
<input type="checkbox" id="chk1" value="1" onClick="showSchoolInfoFields(this);" /> <b class="account">click here, if the student is transferred from another school</b>
<div id="div1" style="display:none;">
<div class="col-sm-4 col-sm-push-1">
<div class="text-center margin-vertical-20">
<h3><i class="fa fa-university"></i> <?php echo get_phrase('school_information');?></h3>
</div>
<div class="form-group">
<label class="control-label" for="school_name"><?php echo get_phrase('school_name');?></label>
<input type="text" placeholder="Bal Batika Vidya Mandir" class="form-control" id="school_name" name="school_name" required="required">
</div>
<div class="form-group">
<label class="control-label" for="school_address"><?php echo get_phrase('school_address');?></label>
<input type="text" placeholder="Banepa 5, Kavre" class="form-control" id="school_address" name="school_address" required="required">
</div>
<div class="form-group">
<label class="control-label" for="inputPhone"><?php echo get_phrase('school_phone_number');?></label>
<div class="input-group">
<span class="input-group-addon">
<b><?php echo get_phrase('+977');?></b>
</span>
<input type="number" placeholder="01422786" class="form-control" id="inputPhone" name="school_phone" required="required">
</div>
</div>
</div>
</div>