【发布时间】:2014-04-04 02:54:10
【问题描述】:
我只想在选中复选框时提交表单,或者显示“请选中复选框”,有什么办法吗?谁能指导我?
谢谢
<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>
【问题讨论】:
-
你应该先自己尝试一下。
-
我认为你的问题标题是错误的。我读了它,因为当您单击复选框时应该提交表单。
-
当我选中复选框并单击提交按钮时,不应提交任何表单,如果我在未选中复选框的情况下提交按钮,我不想提交表单
-
有没有可能有多个复选框?
标签: javascript jquery ajax checkbox