在这里,我有多个带复选框的记录。 一旦我提交,它就会给出错误,因为我创建了#34;你必须选择一个复选框"。 当我选择"选择所有"复选框,它将选中复选框中所有复选框的复选框。 但是,当我取消选中特定页面的复选框并检查其他页面时,它也会在我提交时选中复选框时出错。 那么我在这个带分页的复选框验证中出错了吗?
我的代码:
# Change
open(file_in, 'r')
open(file_out, 'w')
# to
input_file = open(file_in, 'r')
output_file = open(file_out, 'w')
for ln in input_file:
# do your processing
if res:
lemme = res.group(3)
output_file.write(str(lemme) + "\n")
答案 0 :(得分:0)
尝试在if-statment之前添加额外的检查,如下所示:
$('#processorder').click(function() {
checked = $("input[type=checkbox]:checked").length > 0; //Extra check
if(!checked) {
alert("Please select an Order(s)..!!");
return false;
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" name="chk[]" value="Apples" />
<input type="checkbox" name="chk[]" value="Bananas" />
<div style="text-align: center;margin-bottom: 10px;"><input type="submit" id="processorder" name="processorder" value="Process Order" class="submit-green"/></div>
将以下片段删掉,希望有所帮助!
/ Zorken17
答案 1 :(得分:-1)
正如您所看到的,您有一条额外的行会导致此错误。只需删除它就可以了。
小提琴:http://jsfiddle.net/bxvfn652/
$('#processorder').click(function() {
checked = $("input[type=checkbox]:checked").length;
if(!checked) {
alert("Please select an Order(s)..!!");
return false;
}
});
}); /*this line breaks your code. */