我需要防止用户在单击“提交”按钮(代码)后移动到另一页
<div class="form"><div class="pull-left"><input type="checkbox" name="agree" value="check"> I have read and agree to the <a href="#" target="_blank" class="agree"><b>Copyright Declaration</b></a></div></div>
<button type="submit" name="add" id="addtocart" class="btn" onclick="if(!this.form.agree.checked){alert('You must agree to the Copyright Declaration.');return false}" >
答案 0 :(得分:0)
在表单标签中创建一个名为
的属性onsubmit="if(!this.form.agree.checked){alert('You must agree to the Copyright Declaration.');return false}"