“同意条款"-复选框 [英] "Agree on Terms"-checkbox
本文介绍了“同意条款"-复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您将如何为 ... 而不是
... 创建同意条款...复选框?
How would you create a Agree on Terms...-checkbox to a <button>
... and not an <input>
...?
我看到每个人都使用 <input type="checkmark"...>
有一个工作条款复选框到 <input type="submit"...>
I see everyone uses a <input type="checkmark"...>
that has a working Terms-checkbox to a <input type="submit"...>
如何使用此代码获取此类复选框:
How do I get such checkbox with this code:
<button type="submit" class="btn" name="reg_user">Register</button>
我发现使用 的是:
<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>
添加必需":<input type="checkbox" required name="checkbox" value="check" id="agree"/>
使一切正常.
Adding "required": <input type="checkbox" required name="checkbox" value="check" id="agree" />
made everything work.
推荐答案
也许使用 required
属性:
<input type="checkbox" required name="checkbox" value="check" id="agree" />
这篇关于“同意条款"-复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文