"同意条款" -checkbox

时间:2018-01-13 15:51:51

标签: php html

如何创建条款同意......-复选框<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" />使一切正常。

1 个答案:

答案 0 :(得分:0)

也许使用required属性:

<input type="checkbox" required name="checkbox" value="check" id="agree" />