关于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;
    }
  

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

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

这是我在这一次项目中碰到的一些问题点,有时间能够穷究为何id取值须要猎取婚配元素鸠合中每一个元素紧邻的前一个同胞元素,迎接指点的小伙伴们穷究。

    原文作者:MichaelDuan
    原文地址: https://segmentfault.com/a/1190000006826814
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞