分组作业的弹框增加人数的验证、点击关闭弹框时还原弹框中的值
This commit is contained in:
parent
caa966c85a
commit
43192b8648
|
@ -3,11 +3,14 @@
|
|||
<div class="mt10">
|
||||
<span class="f14 fontGrey3 mr5">每组最小人数:</span>
|
||||
<input id="min_num" type="text" name="" class="markInput" value="<%=(edit_mode && homework.is_group_homework?) ? homework.homework_detail_group.min_num : 2 %>" />人
|
||||
<span class="c_red undis" id="min_num_notice"></span>
|
||||
</div>
|
||||
<div class="mt10">
|
||||
<span class="f14 fontGrey3 mr5">每组最大人数:</span>
|
||||
<input id="max_num" type="text" name="" class="markInput" value="<%=(edit_mode && homework.is_group_homework?) ? homework.homework_detail_group.max_num : 10 %>" />人
|
||||
<span class="c_red undis" id="max_num_notice"></span>
|
||||
</div>
|
||||
<p class="c_red undis" id="min_max_num_notice"></p>
|
||||
<div class="mb10 mt10">
|
||||
<label>
|
||||
<input type="checkbox" class="mr5" name="base_on_project" value="<%=(edit_mode && homework.is_group_homework?) ? homework.homework_detail_group.base_on_project : 1 %>" id="base_on_project"/>
|
||||
|
|
|
@ -194,9 +194,11 @@ $(function(){
|
|||
$("#GroupPopupBox").dialog("open");
|
||||
$(".ui-dialog-titlebar").hide();
|
||||
$("a.popClose").on('click', function(){
|
||||
reset_group_attr();
|
||||
$("#GroupPopupBox" ).dialog("close");
|
||||
});
|
||||
$("#cancel_group").on('click', function(){
|
||||
reset_group_attr();
|
||||
$("#GroupPopupBox" ).dialog("close");
|
||||
});
|
||||
$('#min_num').focus();
|
||||
|
@ -351,29 +353,67 @@ $(function(){
|
|||
$("#GroupPopupBox").dialog("open");
|
||||
$(".ui-dialog-titlebar").hide();
|
||||
$("a.popClose").on('click', function () {
|
||||
reset_group_attr();
|
||||
$("#GroupPopupBox").dialog("close");
|
||||
});
|
||||
$("#cancel_group").on('click', function () {
|
||||
reset_group_attr();
|
||||
$("#GroupPopupBox").dialog("close");
|
||||
});
|
||||
$('#min_num').focus();
|
||||
}
|
||||
});
|
||||
|
||||
var reset_group_attr = function() {
|
||||
$("#min_num_notice").hide();
|
||||
$("#min_max_num_notice").hide();
|
||||
$("#max_num_notice").hide();
|
||||
if($("input[name=min_num]").length > 0 && $("input[name=max_num]").length > 0) {
|
||||
$("#min_num").val($("input[name=min_num]").val());
|
||||
$("#max_num").val($("input[name=max_num]").val());
|
||||
} else {
|
||||
$("#min_num").val(2);
|
||||
$("#max_num").val(10);
|
||||
}
|
||||
};
|
||||
var saveGroupAttr = function() {
|
||||
var valid = true;
|
||||
var base_on_project = 0;
|
||||
var min = $.trim($("#min_num").val());
|
||||
var max = $.trim($("#max_num").val());
|
||||
if(min.length <= 0) {
|
||||
var regex = /^\d+$/;
|
||||
if(!regex.test(min) || parseInt(min) <= 0) {
|
||||
$("#min_num_notice").html("请输入正整数");
|
||||
$("#max_num_notice").html("");
|
||||
$("#min_max_num_notice").html("");
|
||||
$("#min_num_notice").show();
|
||||
$("#min_num").focus();
|
||||
valid = false;
|
||||
return false;
|
||||
} else {
|
||||
$("#min_num_notice").html("");
|
||||
$("#min_num_notice").hide();
|
||||
}
|
||||
if(max.length <= 0) {
|
||||
if(!regex.test(max) || parseInt(max) <= 0) {
|
||||
$("#max_num_notice").html("请输入正整数");
|
||||
$("#min_num_notice").html("");
|
||||
$("#min_max_num_notice").html("");
|
||||
$("#max_num_notice").show();
|
||||
$("#max_num").focus();
|
||||
valid = false;
|
||||
return false;
|
||||
} else {
|
||||
$("#max_num_notice").html("");
|
||||
$("#max_num_notice").hide();
|
||||
}
|
||||
if(parseInt(min) > parseInt(max)) {
|
||||
$("#min_max_num_notice").html("最小人数不得大于最大人数");
|
||||
$("#min_num_notice").html("");
|
||||
$("#max_num_notice").html("");
|
||||
$("#min_max_num_notice").show();
|
||||
$("#max_num").focus();
|
||||
return false;
|
||||
} else {
|
||||
$("#min_max_num_notice").html("");
|
||||
$("#min_max_num_notice").hide();
|
||||
}
|
||||
if ($("#base_on_project").is(":checked")) {
|
||||
base_on_project = 1;
|
||||
|
|
Loading…
Reference in New Issue