簡體   English   中英

轉到其他頁面之前,請檢查復選框是否已選中

[英]Checking that checkbox is checked before going to other page

我有一張縮略圖,單擊該縮略圖可鏈接到另一頁。 並且我想確保用戶在單擊縮略圖圖片以轉到另一頁之前,已經選中了一個復選框。

我的Javascript函數當前為:

function CheckForm(obj1) { 

if (obj1.accept.checked == false){
  alert ("You must check the box to confirm you have read and accept the Terms.");
return false;
} 
return true;
}

我的html看起來像這樣:

<input name="accept" type="checkbox" value="0">Confirmation Box</input>

<a href="http://somelink.com">
<img src="/Koala.jpg" height="94" width="94" />
</a>

因此,我希望用戶必須先選中該復選框,然后才能單擊koala.jpg縮略圖。 因此,只有選中該復選框,用戶才能進入somelink.com。

<a href="http://somelink.com" onclick="return CheckForm()">


function CheckForm(obj1) { 

if (!($('#accept').is(":checked"))){
  alert ("You must check the box to confirm you have read and accept the Terms.");
return false;
} 
return true;
}

這個問題的標簽中列出了jquery,所以我假設您可以訪問該庫:

jQuery('#name').is(':checked') == false

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM