radio校验
This commit is contained in:
parent
d39fd56281
commit
6c55297aa4
@ -109,7 +109,7 @@
|
|||||||
<td>
|
<td>
|
||||||
{{# for(var j = 0, jItem; jItem = item.checkItemOptions[j++]; ) { }}
|
{{# for(var j = 0, jItem; jItem = item.checkItemOptions[j++]; ) { }}
|
||||||
{{# if(jItem.type == 1) { }}
|
{{# if(jItem.type == 1) { }}
|
||||||
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="{{jItem.checkItemOptionId}}" title="{{jItem.name}}" data-checktype="{{item.type}}" data-type="{{jItem.type}}" data-iswrong="{{jItem.isWrong}}" lay-filter="checkItemOptionCheckResult">
|
<input type="radio" name="hd_checkResult_{{item.checkItemId}}" value="{{jItem.checkItemOptionId}}" title="{{jItem.name}}" data-checktype="{{item.type}}" data-type="{{jItem.type}}" data-iswrong="{{jItem.isWrong}}" lay-filter="checkItemOptionCheckResult" lay-verify="otherReq">
|
||||||
{{# } else if(jItem.type == 2) { }}
|
{{# } else if(jItem.type == 2) { }}
|
||||||
<div class="check-item-option-number-box"><span>{{jItem.name}}</span>:<input class="check-item-option-number-input" id="hd_checkNumber_{{item.checkItemId}}_{{jItem.checkItemOptionId}}" name="hd_checkNumber_{{item.checkItemId}}_{{jItem.checkItemOptionId}}" type="number" step="1"/> <span>{{jItem.unit}}</span></div>
|
<div class="check-item-option-number-box"><span>{{jItem.name}}</span>:<input class="check-item-option-number-input" id="hd_checkNumber_{{item.checkItemId}}_{{jItem.checkItemOptionId}}" name="hd_checkNumber_{{item.checkItemId}}_{{jItem.checkItemOptionId}}" type="number" step="1"/> <span>{{jItem.unit}}</span></div>
|
||||||
{{# } else if(jItem.type == 3) { }}
|
{{# } else if(jItem.type == 3) { }}
|
||||||
@ -477,6 +477,23 @@
|
|||||||
|
|
||||||
// 校验
|
// 校验
|
||||||
form.verify({
|
form.verify({
|
||||||
|
otherReq: function(value,item){
|
||||||
|
var verifyName = $(item).attr('name')
|
||||||
|
,verifyType = $(item).attr('type')
|
||||||
|
,formElem = $(item).parents('.layui-form')//获取当前所在的form元素,如果存在的话
|
||||||
|
,verifyElem = formElem.find('input[name='+verifyName+']')//获取需要校验的元素
|
||||||
|
,isTrue = verifyElem.is(':checked')//是否命中校验
|
||||||
|
,focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
|
||||||
|
if(!isTrue || !value){
|
||||||
|
//定位焦点
|
||||||
|
focusElem.css(verifyType=='radio' ? {"color":"#FF5722"} : {"border-color":"#FF5722"});
|
||||||
|
//对非输入框设置焦点
|
||||||
|
focusElem.first().attr("tabIndex","1").css("outline","0").blur(function() {
|
||||||
|
focusElem.css(verifyType=='radio' ? {"color":""} : {"border-color":""});
|
||||||
|
}).focus();
|
||||||
|
return '必填项不能为空';
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// area1 选择事件
|
// area1 选择事件
|
||||||
|
Loading…
Reference in New Issue
Block a user