关于easyui datebox 的选择器,属性 以及 取值。

最近做项目 用到了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取值需要获取匹配元素集合中每个元素紧邻的前一个同胞元素,欢迎指导的小伙伴们深究。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值