如何创建条款同意......-复选框<button>
...而不是<input>
...?
我看到每个人都使用<input type="checkmark"...>
<input type="submit"...>
<{1}}
如何使用此代码获取此复选框:
<button type="submit" class="btn" name="reg_user">Register</button>
我发现使用<input>
的是:
<form action="#" onsubmit="if(document.getElementById('agree').checked) { return true; } else { alert('Please indicate that you have read and agree to the Terms and Conditions and Privacy Policy'); return false; }">
<input type="checkbox" name="checkbox" value="check" id="agree" /> I have read and agree to the Terms and Conditions and Privacy Policy
<input type="submit" name="submit" value="Register" />
</form>
解决方案:
<form action="#" onsubmit="if(document.getElementById('agree').checked) { return true; } else { alert('Please indicate that you have read and agree to the Terms and Conditions and Privacy Policy'); return false; }">
<input type="checkbox" required name="checkbox" value="check" id="agree" /> I have read and agree to the Terms and Conditions and Privacy Policy
<button type="submit" class="btn" name="reg_user">Register</button>
</form>
添加&#34;必需&#34;:<input type="checkbox" required name="checkbox" value="check" id="agree" />
使一切正常。
答案 0 :(得分:0)
也许使用required
属性:
<input type="checkbox" required name="checkbox" value="check" id="agree" />