This topic is locked

Limiting dates in Date Picker

7/4/2007 4:45:36 AM
PHPRunner General questions
K
kenny_robb author

I am trying to stop people picking a date in the future in the date picker....
I have no idea even where to start....any suggestions would be welcome...
Thanks in anticipation
Kenny

J
Jane 7/4/2007

Kenny,
you can do it editing calendar.htm file manually.

Find this code:

var currentyear=(new Date()).getFullYear();

var lo=currentyear-100;

var hi=currentyear+10;

if(dt_current.getFullYear()>hi-10)

hi=dt_current.getFullYear()+1;

and replace it with this one:

var currentyear=(new Date()).getFullYear();

var lo=currentyear-100;

var hi=currentyear;

L
larsonsc 7/4/2007

Jane,
What instance of calendar.html are we supposed to edit? I have tried editing the file that gets built up to the web server and the one in the /source folder in the application folder. Neither edit has produced the change in the date picker fields in my project. They still show 100 yrs back and 10 yrs forward. I even rebuilt my project after editing the copy of calendar.html in the source folder.

Original Code:

var currentyear=(new Date()).getFullYear();

var lo=currentyear-100;

var hi=currentyear+10;

if(dt_current.getFullYear()>hi-10)

hi=dt_current.getFullYear()+10;

if(dt_current.getFullYear()<lo+10)

lo=dt_current.getFullYear()-10;


Edited Code:

var currentyear=(new Date()).getFullYear();

var lo=currentyear-10;

var hi=currentyear;

if(dt_current.getFullYear()<lo+10)

lo=dt_current.getFullYear()-10;


What am I doing wrong to get this to actually take effect on my project?

K
kenny_robb author 7/5/2007

Ah now I see.
I want to stop people entering things for tomorrows date or in the future.
They can enter dates in the past.
Kenny