我想知道如何让复选框删除表单中特定无线电组的“必需”验证。如果选中该复选框,我不希望强制执行“必需”属性。这是我现有 HTML 的示例:https : //codepen.io/anon/pen/PrbOPK<label for="Group1_notRequired">Check here to make radio buttons in Gorup 1 NOT required:</label> <input id="Group1_notRequired" name="Group1_notRequired" type="checkbox" value="Group1_notRequired" /><br><br><br><label><input name="Group1" required="" type="radio" value="Option1" />Group 1 Option 1</label><label><input name="Group1" required="" type="radio" value="Option2" />Group 1 Option 2</label><br><br><br><label><input name="Group2" required="" type="radio" value="Option1" />Group 2 Option 1</label><label><input name="Group2" required="" type="radio" value="Option2" />Group 2 Option 2</label>
2 回答
蓝山帝景
TA贡献1843条经验 获得超7个赞
我的建议:
$radioG1 = $('[name="Group1"]')
$cbxG1 = $('#Group1_notRequired')
$cbxG1.change(function() {
$radioG1.prop("required", !this.checked)
})
添加回答
举报
0/150
提交
取消