近来做项目 用到了easyui内里的相干datebox的操纵 做以下总结
发明 datebox是不支持input框 id选择器的一些取值要领,只能如许取 var idValue = $(“#effectiveDateDx”).datebox(“getValue”);不能装置寻常的要领取,比方:
var value = $("#effectiveDate").val(); 而且 也不支持id选择器的事宜处置惩罚。经由测试 运用以下体式格局能够取到 datebox的值。
name选择器:
<td class="fieldlabel" style="width: 80px"><span
i18n="commission.effectiveDate">见效日期</span> <span class="red">*</span>
</td>
<td align="left" style="width: 140px">
<input type="text" name="effectiveDate"
id = "effectiveDateDx" class="easyui-datebox easyui-validatebox"
style="width: 165px" data-options="required:true,validType:['datebox']">
<span id="effectiveDateMsg"></span>
</td>
取值;
var dateValue = $("input[name='effectiveDate']").prev().val();
给datebox加上blur事宜;
$("input[name='effectiveDate']").prev().blur(function(){
var linePrice = $("input[name='effectiveDate']").prev().val();
if(linePrice == null || linePrice == ''){
$("#effectiveDateMsg").text("不能为空!");
$("#effectiveDateMsg").addClass("error_msg");
}else if(!checkDate(linePrice)){
$("#effectiveDateMsg").text("请准确输入!");
$("#effectiveDateMsg").addClass("error_msg");
}else{
$("#effectiveDateMsg").text("");
}
})
//推断日期花样(yyyy-MM-dd)
function checkDate(str){
var reg = /^(\d{4})-(\d{2})-(\d{2})$/;
var arr = reg.exec(str);
if (str=="") return true;
if (!reg.test(str)&& RegExp.$2<=12 && RegExp.$3<=31){
return false;
}
return true;
}
这是我在这一次项目中碰到的一些问题点,有时间能够穷究为何id取值须要猎取婚配元素鸠合中每一个元素紧邻的前一个同胞元素,迎接指点的小伙伴们穷究。