我想僅在選中複選框時提交表單,或者顯示「請選中複選框」,有沒有辦法做到這一點?任何人都可以引導我嗎?如何檢查複選框時提交表單?
感謝
<form name="myForm" action="mailsent.php" method="post">
<input type="checkbox" class="chk_row" name="chk1[]"" value=" '.$rows["id"].'"/>
<input type="submit" value="" style="margin:7px 26px -27px 1424px;background-image: url(/image/exporttt.png);background-repeat: no-repeat;cursor:pointer;" >
</form>
編輯的代碼:
<form name="myForm" action="mailsent.php" method="post">
<input type="checkbox" class="chk_row" id="chk1" name="chk1[]"" value=" '.$rows["id"].'"/>
<input type="submit" value="" style="margin:7px 26px -27px 1424px;background-image: url(/image/exporttt.png);background-repeat: no-repeat;cursor:pointer;" >
</form>
<script>
$('form').submit(function(){
if(!$('#chk1').is(':checked')){
alert("Please Check ");
return false;
}
});
</script>
您應該先嚐試一下。 –
可能重複[提交表單時檢查複選框](http://stackoverflow.com/questions/10602470/submitting-a-form-when-a-checkbox-is-checked) – Rikesh
我認爲你的問題標題是錯誤。我閱讀它時應單擊複選框提交表單。 – RRikesh