easyUI 单选按钮回显 与隐藏
程序员文章站
2022-07-07 19:58:32
...
检查结果为合格时,显示合格证号,并且为必填, 否则就隐藏合格证号,并且不必填
<tr>
<th width="15%">检验结果</th>
<td width="35%">
<span class="radioSpan">
<input type="radio" name="deteresult" value="01" checked="checked" onclick="checkIsMin(this.value)">合格</input>
<input type="radio" name="deteresult" value="02" onclick="checkIsMin(this.value)">不合格</input>
</span>
</td>
<th width="15%" class="jyhgzh">检验合格证号</th>
<td class="jyhgzh">
<input type="text" value="${model.detecertificate}" name="detecertificate" id="detecertificate" class="easyui-textbox" required="true" data-options="validType:length[0,50]"/>
</td>
</tr>
//检验结果改变加载事件
$("input[name='deteresult']").each(function(){
if('${model.deteresult}'==$(this).val()){
$(this).prop("checked",true);
if($(this).val()=='02'){
$('.jyhgzh').attr("style","display:none");
$("#detecertificate").textbox({ required:false });
}
}
});
//检查是否合格,不合格就隐藏合格证号
function checkIsMin(value){
if(value=="01"){
$(".jyhgzh").removeAttr("style");
$("#detecertificate").textbox({ required:true });
}
if(value=="02"){
$('.jyhgzh').attr("style","display:none");
$("#detecertificate").textbox({ required:false });
}
}
<tr>
<th width="15%">检验结果</th>
<td width="35%">
<span class="radioSpan">
<input type="radio" name="deteresult" value="01" checked="checked" onclick="checkIsMin(this.value)">合格</input>
<input type="radio" name="deteresult" value="02" onclick="checkIsMin(this.value)">不合格</input>
</span>
</td>
<th width="15%" class="jyhgzh">检验合格证号</th>
<td class="jyhgzh">
<input type="text" value="${model.detecertificate}" name="detecertificate" id="detecertificate" class="easyui-textbox" required="true" data-options="validType:length[0,50]"/>
</td>
</tr>
//检验结果改变加载事件
$("input[name='deteresult']").each(function(){
if('${model.deteresult}'==$(this).val()){
$(this).prop("checked",true);
if($(this).val()=='02'){
$('.jyhgzh').attr("style","display:none");
$("#detecertificate").textbox({ required:false });
}
}
});
//检查是否合格,不合格就隐藏合格证号
function checkIsMin(value){
if(value=="01"){
$(".jyhgzh").removeAttr("style");
$("#detecertificate").textbox({ required:true });
}
if(value=="02"){
$('.jyhgzh').attr("style","display:none");
$("#detecertificate").textbox({ required:false });
}
}