For jn only

1. Open /media/system/js/calendar-setup.js file and replace the following code:



if(params.inputField==’date_of_appointment’) param_default(“disableFunc”,disableDate); else param_default(‘disableFunc’,null);

2. Open your view file and place this to display calendar control.

$document    = & JFactory::getDocument();
echo JHTML::_(‘calendar’,”, ‘date_of_appointment’, ‘date_of_appointment’, ‘%Y-%m-%d’, array(‘class’=>’inputbox’, ‘size’=>’8’, ‘maxlength’=>’19’));

On the same page add the following JS code:

function disableDate(d)
today = new Date();
difference = d – today;
days = Math.round(difference/(1000*60*60*24));
if( days > -1 )return false;
return true;

That’s it. Chargeable. 😀

There is only single problem on which I’m working. In that when u select today’s date, after that u will not be able to select any other dates. its working fine when u select other dates except today. will let u know once its done.

  1. Hurray……I found the problem and resolved it. Kindly update the following function code with the original.

    function disableDate(d)
    dt = new Date(d.getFullYear() + ‘ ‘ + (d.getMonth() + 1) + ‘ ‘ + d.getDate()); //calendar date object
    today = new Date(); //today’s date object
    tdy = new Date(today.getFullYear() + ‘ ‘ + (today.getMonth() + 1) + ‘ ‘ + today.getDate());
    difference = dt – tdy;
    days = Math.round(difference/(1000*60*60*24));
    if (days > -1)
    return false;
    return true;

      • khushi
      • August 30th, 2011


      I have written same function for the joomla but it gives me javascript error

      Error: d.getFullYear is not a function

      The line where error occurs is this
      dt = new Date(d.getFullYear() + ” + (d.getMonth() + 1) + ” + d.getDate()); //calendar date object

      please check and reply soon so I can update code

      Alternate I thought is….
      Explode the Date from seperator and set that 2011-08-23
      Hope that is fine ?

      • Hey dear Khushi,

        I think the problem is with the incoming value of variable d which mayn’t match with appropriate type required to get value of year, month & day using JS functions such as getFullYear(), getMonth() & getDate(). Please make sure it is correct OR you can just customize it to assign value of dt=new Date(YOUR CUSTOMIZED/FORMATTED DATE);

        Let me know if you still have any problem with that. Thank you.

    • khushi
    • August 30th, 2011

    thanks a lot for your quick reply.

    I found what was the exact issue and resolved it.
    I added one new line in the function that is
    var d = new Date(d);
    dt = new Date(d.getFullYear() + ‘ ‘ + (d.getMonth() + 1) + ‘ ‘ + d.getDate()); //calendar date object

    so this d=new Date will convert my calendar date format in the format which is the default date format of javascript.


  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: