提交带有锚标记的按钮

时间:2013-10-14 15:26:15

标签: html forms

我有一个带有两个提交按钮的联系表格(按钮都具有相同的功能,除了一个在页面的上方)

两个按钮都有验证(如果未勾选复选框,则会弹出警告)

如果单击页面上方的提交按钮并且验证未完成,我希望页面跳到底部。

我尝试使用锚标记包装输入按钮:

<a href="#seccta">t<input type="image" src="http://fc01.deviantart.net/fs71/f/2010/108/c/5/Green_Submit_Button_by_rukiaxichigo15.jpg" onclick="if(!this.form.checkbox.checked){alert('Please read and agree to the terms and conditions first.');return false}"  /></a>

并将锚码放在文档的底部:

<a name="seccta"> </a>

......但它不起作用。它在我放置文本时有效,但是提交按钮会将其分解。

2 个答案:

答案 0 :(得分:0)

而不是包裹按钮,而是将其放在按钮之前或之后

<a href="#seccta">t</a><input type="image" src="http://fc01.deviantart.net/fs71/f/2010/108/c/5/Green_Submit_Button_by_rukiaxichigo15.jpg" onclick="if(!this.form.checkbox.checked){alert('Please read and agree to the terms and conditions first.');return false}"  />

对于用户来说,它不会做任何改变,因为你会在按钮之后/之前指向右边。如果你需要使用空白字符

<a href="#seccta">&nbsp;</a>

试试吧

答案 1 :(得分:0)

好的,我在锚点上添加了另一个onclick,这解决了我的问题:

location.href='#seccta'; if(!this.form.checkbox.checked){alert('Please read and agree to the terms and conditions first.');return false};
相关问题