如何在easyui-datebox中设置初始值和范围

问题描述 投票:0回答:1

我有一个easyui-datebox访问它,提示日期形式jan 1970我怎么能让他们最初显示当前日期(即)有什么像setInitialDate()也如何我设置日期范围像setStartDate()setEndDate()

javascript jquery-ui jquery-easyui
1个回答
0
投票

这是一个问题:JQuery easyui and Datejs date conflict。当您使用带easyui的Date.js时,会出现此问题。如果从Web资源中删除Date.js,则打开日期框会在第一次弹出时自动显示当前日期。解决方法是在启动日期字段后使用以下代码。

$('#dateDuetxt').datebox({
    value: (new Date().toString('dd-MMM-yyyy')) /* Date.js toString function to convert date into format that is being used by datebox. */
});

完整的示例代码是:

Due Date <input id="dateDuetxt" class="easyui-datebox" style="width:100px"/>  

<script>

$('#dateDuetxt').datebox({
    value: (new Date().toString('dd-MMM-yyyy')), /* Date.js toString function to convert date into format that is being used by datebox. */
    formatter : function(date){
        return date.toString('dd-MMM-yyyy');
    },
    parser : function(s){
        var t = Date.parse(s);
        if (!isNaN(t)){
            return new Date(t);
        } else {
            return null;
        }
    }
});

</script>

但是,如果从页面中删除Date.js,则不需要编写脚本,只需创建日期框即可

Due Date <input id="dateDuetxt" class="easyui-datebox" style="width:100px"/>

会做的伎俩。

© www.soinside.com 2019 - 2024. All rights reserved.