Php 如何在默认DHTML日历中禁用前几天?

Php 如何在默认DHTML日历中禁用前几天?,php,javascript,dhtml,Php,Javascript,Dhtml,如何在默认DHTML日历中禁用前几天 我使用了以下代码 <script type="text/javascript"> Calendar.setup({ inputField : '_dob', ifFormat : '%m/%e/%y', button : '_dob_trig', align : 'Bl', singleClick : true, disableFunc: functio

如何在默认DHTML日历中禁用前几天

我使用了以下代码

<script type="text/javascript">
 Calendar.setup({
        inputField : '_dob',
        ifFormat : '%m/%e/%y',
        button : '_dob_trig',
        align : 'Bl',
        singleClick : true,
      disableFunc: function(date) {
          var now= new Date();
        return (date.getTime() < now.getTime());
    }
    });
</script>

日历设置({
输入字段:''u dob',
ifFormat:“%m/%e/%y”,
按钮:“_dob_trig”,
对齐:“Bl”,
单键点击:对,
disableFunc:函数(日期){
var now=新日期();
return(date.getTime()
它用于禁用以前的日期。但当我们选择有效日期时,什么也不会发生。日期未添加到日历的文本字段中

如果我更改月份并返回,我可以选择日期


有什么想法吗?

禁用函数应始终返回TRUE或FALSE

disableFunc函数:接收JS日期对象的函数。如果必须禁用该日期,则返回true,否则返回false。已弃用(见下文)。

请参考以下内容:

但在代码中,禁用函数不返回任何内容…:(因此进入js错误,事件单击时没有任何效果。)

检查你的情况

return (date.getDate() <= now.getDate());

return(date.getDate()禁用函数应始终返回TRUE或FALSE

disableFunc函数:接收JS日期对象的函数。如果必须禁用该日期,则返回true,否则返回false。已弃用(见下文)。

请参考以下内容:

但在您的代码中,disable函数不返回任何东西…:(因此它进入js错误,在事件单击时没有任何东西起作用。)

检查你的情况

return (date.getDate() <= now.getDate());
return(date.getDate()尝试下面的代码

 Calendar.setup({
            inputField : '_dob',
            ifFormat : '%m/%e/%y',
            button : '_dob_trig',
            align : 'Bl',
            singleClick : true,
            dateStatusFunc :    function (date) { 
                var now= new Date();
                return (date.getDate() <= now.getDate());
            }
        });
Calendar.setup({
输入字段:''u dob',
ifFormat:“%m/%e/%y”,
按钮:“_dob_trig”,
对齐:“Bl”,
单键点击:对,
dateStatusFunc:函数(日期){
var now=新日期();
return(date.getDate()尝试下面的代码

 Calendar.setup({
            inputField : '_dob',
            ifFormat : '%m/%e/%y',
            button : '_dob_trig',
            align : 'Bl',
            singleClick : true,
            dateStatusFunc :    function (date) { 
                var now= new Date();
                return (date.getDate() <= now.getDate());
            }
        });
Calendar.setup({
输入字段:''u dob',
ifFormat:“%m/%e/%y”,
按钮:“_dob_trig”,
对齐:“Bl”,
单键点击:对,
dateStatusFunc:函数(日期){
var now=新日期();
return(date.getDate()Wow

这可能是一些javascript错误。我无法选择任何日期,除非从下个月开始来回

我通过给出一些if循环来克服它。下面是我更新的代码

<script type="text/javascript">
 Calendar.setup({
        inputField : '_dob',
        ifFormat : '%m/%e/%y',
        button : '_dob_trig',
        align : 'Bl',
        singleClick : true,
        disableFunc: function(date) {
          var now= new Date();
        if(date.getFullYear()<now.getFullYear())
        {
            return true;
        }
        if(date.getFullYear()==now.getFullYear())
        {
            if(date.getMonth()<now.getMonth())
            {
                return true;
            }
        }
        if(date.getMonth()==now.getMonth())
        {
            if(date.getDate()<now.getDate())
            {
                return true;
            }
        }
    },
    });
</script>

日历设置({
输入字段:''u dob',
ifFormat:“%m/%e/%y”,
按钮:“_dob_trig”,
对齐:“Bl”,
单键点击:对,
disableFunc:函数(日期){
var now=新日期();
如果(date.getFullYear()Wow

这可能是一些javascript错误。我无法选择任何日期,除非从下个月开始来回

我通过给出一些if循环来克服它。下面是我更新的代码

<script type="text/javascript">
 Calendar.setup({
        inputField : '_dob',
        ifFormat : '%m/%e/%y',
        button : '_dob_trig',
        align : 'Bl',
        singleClick : true,
        disableFunc: function(date) {
          var now= new Date();
        if(date.getFullYear()<now.getFullYear())
        {
            return true;
        }
        if(date.getFullYear()==now.getFullYear())
        {
            if(date.getMonth()<now.getMonth())
            {
                return true;
            }
        }
        if(date.getMonth()==now.getMonth())
        {
            if(date.getDate()<now.getDate())
            {
                return true;
            }
        }
    },
    });
</script>

日历设置({
输入字段:''u dob',
ifFormat:“%m/%e/%y”,
按钮:“_dob_trig”,
对齐:“Bl”,
单键点击:对,
disableFunc:函数(日期){
var now=新日期();

如果(date.getFullYear()我遇到了相同的问题,并且在调试之后,问题似乎是日历无法确定当前日历日期应该是什么(因为它被disableFunc回调函数禁用)。您有两个可用选项

  • 确保disableFunc函数对于当前日期返回false。这样,它就不会在日历中被禁用,并且可以正常工作
  • 您可以在calendar.js中的if(!cell.disabled)行之后添加以下行。(这恰好是我的文件版本-v1.51中的第1183行)

    否则 { this.currentDatel=单元格; }

  • 第二个选项也允许您禁用当前日期


    对于那些想知道这个DHTML日历是什么的人,这里有一个指向它的文档的链接:

    我也遇到了同样的问题,调试后,问题似乎是日历无法确定当前日历日期应该是什么(因为它被disableFunc回调函数禁用)。您有两个选项可用

  • 确保disableFunc函数对于当前日期返回false。这样,它就不会在日历中被禁用,并且可以正常工作
  • 您可以在calendar.js中的if(!cell.disabled)行之后添加以下行。(这恰好是我的文件版本-v1.51中的第1183行)

    否则 { this.currentDatel=单元格; }

  • 第二个选项也允许您禁用当前日期


    对于那些想知道这个DHTML日历是什么的人,这里有一个指向它的文档的链接:

    但不会
    (date.getDate()很有趣!代码似乎是正确的!但我只能选择日期,如果我去上个月回来…!我编辑了问题…但不会
    (date.getDate())很有趣!代码似乎是正确的!但是我只能选择上个月的日期然后回来…!我编辑了这个问题…你能提供到你的日历库的链接吗?????你能指出如何在DHTML日历中获取完整日期吗?你能提供到你的日历库的链接吗?????你能指出如何在DHTML cal中获取完整日期吗endar?不工作。当前js-“(date.getTime()