只有在用户单击超链接(条款和条件?)后才能选中复选框吗?
Can a checkbox only be checked after a user clicks a hyperlink (Terms and Conditions?)?
我正在尝试编写一个表单,其中用户 select 一个选项,某些表单作为该选项的结果显示——我在 jquery 上工作得很好。接下来,我试图让用户在选中复选框之前必须单击指向条款和条件的超链接。
我见过多个用户必须单击复选框才能看到超链接的示例,但我想知道是否可以反过来。
<div id="additionalForm" class="FormDiv">
<fieldset>
<legend>Housing Agreement</legend>
<input id="chkSignature" name="chkSignature" type="checkbox" required>
<label for="chkSignature">
<b>I have read and I agree to the
<a href="TermsandConditions.asp" target="_blank">Terms and Conditions</a>
</b>
</label>
</fieldset>
</div>
现在,我对复选框进行了验证,但我无法查看它们是否真的在阅读超链接中的内容。我想让用户先单击我的 HTML 中的超链接,然后才能选中该框。
- 在复选框上添加了
disabled
属性
- 为 link
的点击添加了点击事件侦听器
- 单击 link 时删除了禁用属性
document.querySelector('#termsAndConditions')
.addEventListener('click', function(e){
document.querySelector('#chkSignature').removeAttribute('disabled');
});
<div id="additionalForm" class="FormDiv">
<fieldset>
<legend>Housing Agreement</legend>
<input id="chkSignature" name="chkSignature" type="checkbox" required disabled>
<label><b>I have read and I agree to the <a href="TermsandConditions.asp" target="_blank" id="termsAndConditions">Terms and Conditions</a></b></label>
</fieldset>
</div>
我正在尝试编写一个表单,其中用户 select 一个选项,某些表单作为该选项的结果显示——我在 jquery 上工作得很好。接下来,我试图让用户在选中复选框之前必须单击指向条款和条件的超链接。
我见过多个用户必须单击复选框才能看到超链接的示例,但我想知道是否可以反过来。
<div id="additionalForm" class="FormDiv">
<fieldset>
<legend>Housing Agreement</legend>
<input id="chkSignature" name="chkSignature" type="checkbox" required>
<label for="chkSignature">
<b>I have read and I agree to the
<a href="TermsandConditions.asp" target="_blank">Terms and Conditions</a>
</b>
</label>
</fieldset>
</div>
现在,我对复选框进行了验证,但我无法查看它们是否真的在阅读超链接中的内容。我想让用户先单击我的 HTML 中的超链接,然后才能选中该框。
- 在复选框上添加了
disabled
属性 - 为 link 的点击添加了点击事件侦听器
- 单击 link 时删除了禁用属性
document.querySelector('#termsAndConditions')
.addEventListener('click', function(e){
document.querySelector('#chkSignature').removeAttribute('disabled');
});
<div id="additionalForm" class="FormDiv">
<fieldset>
<legend>Housing Agreement</legend>
<input id="chkSignature" name="chkSignature" type="checkbox" required disabled>
<label><b>I have read and I agree to the <a href="TermsandConditions.asp" target="_blank" id="termsAndConditions">Terms and Conditions</a></b></label>
</fieldset>
</div>