PDA

View Full Version : Verify Date.


rlemon
05-16-2005, 07:35 PM
I wrote this for another user but i'm unsure if it's exactly what he wants. so i'l post it here!


<script type="text/javascript">
// USER Config
var cd_year=2005; // Year in XXXX format (i.e 2005)
var cd_month=5; // Month in X(X) format (i.e Jan = 1; nov = 11;)
var cd_day=15; // Day in numerical format.

var onDayText = "Today is the day!";
var beforDayText = "Befor Date Text!";
var afterDayText = "After Date Text!";

/* /////////////////OUTPUT/////////////////
Configure this section for the output
right now everything just alerts.
*/
function output(){
if(status == "be"){ /// BEFOR THE CONFIG DATE
// do code
alert(beforDayText);
} else if(status == "af") { // AFTER THE CONFIG DATE
// do code
alert(afterDayText);
} else if(status == "on"){ // ON THE CONFIG DATE
// do code
alert(onDayText);
}
}
/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */
var cd_month = cd_month-1; var monthtext=new Array("Jan","Feb","Mar","April","May","June","July","Aug","Sep","Oct","Nov","Dec"); var today=new Date(); var t_m = (today.getMonth()+1); var t_d = today.getDate(); var t_y = today.getYear(); function check_date(){ if( cd_year < t_y ){month();} else if( cd_year > t_y){month();} else if( cd_year == t_y){month();}
output();}
function day(){ if( cd_day < t_d ){ status ="be";} else if( cd_day > t_d){ status ="af";} else if( cd_day == t_d){ status ="on";}
return status;}
var status=''; var set = false; function month(){ if( cd_month < t_m ){day();} else if( cd_month > t_m){day();} else if( cd_month == t_m){day();}
return status;}

</script>


you need to call check_date() to start the script.