<a href="page.html" > <button type="button" id="proceed-button">Proceed </button></a>
<input type="checkbox" name="checkbox3" value="yes">
By checking the box, I certify that have read the above disclaimers and agree to the rules. </input>
我有一个复选框和一个按钮,它将带我到下一页。但是,在我按下按钮之前,必须勾选复选框。如果没有,则必须在复选框下方显示标签,说明&#34;首先接受规则&#34;。救命?此外,如果我点击继续而不选中复选框,我可以突出显示红色复选框。可以使用javascript / jquery。
答案 0 :(得分:3)
试试这个有效
<form action="page.html">
<input type="checkbox" name="checkbox3" value="yes" required>
By checking the box, I certify that have read the above disclaimers and agree to the rules. </input>
<input type="submit" name ="submit"/>
</form>
答案 1 :(得分:-1)
为了帮助您入门:
<input id="checkboxAgree" type="checkbox" name="checkbox3" value="yes">
function checkAgree()
{
if (document.getElementbyId("checkboxAgree").getAttribute("checked") )//checkbox is checked
{
location.href = "page.html"; //load the next page.
}
else
{
Alert("You need to check the box before you can continue");
}
}
document.getElementById("proceed-button").addEventListener("click", checkAgree ,false);
addEventListener
向onclick
添加button
个事件。单击时,执行函数checkAgree
。当复选框具有属性checked
时,将检查该对象,if
将呈现为真。 location.href
将加载page.html
。
请删除按钮周围的a
。