我想仅在选中复选框时提交表单,或者显示“请选中复选框”,有没有办法做到这一点?任何人都可以引导我吗?如何检查复选框时提交表单?
感谢
<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