2013-10-14 70 views
-1

我有一個接觸的形式與兩個提交按鈕(按鈕都具有相同的功能,除了一個是越往上頁)提交按鈕與錨標記

兩個按鈕對他們的驗證(如果複選框不彈出警告彈出)

如果點擊頁面上方的提交按鈕並且驗證未完成,我希望頁面跳到底部。

我已經試過包裝用錨標記輸入按鈕:

<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> 

...但它不工作。它適用於我放置文本時,但提交按鈕打破它。

+1

什麼提交按鈕? – Liam

+0

對不起,輸入按鈕 – scott

回答

0

好吧,我添加了另一個的onclick到錨並已解決了我的問題:

location.href='#seccta'; if(!this.form.checkbox.checked){alert('Please read and agree to the terms and conditions first.');return false}; 
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> 

試試吧

+0

我只是在示例中使用「t」來表明它與文本一起工作。 如果彈出警告,我希望頁面跳到底部。 – scott