I have a control function like this
function control()
{
if(document.getElementById('valid_fromday').value==document.getElementById('valid_today').value && document.getElementById('valid_frommo').value==document.getElementById('valid_tomo').value && document.getElementById('valid_fromyear').value==document.getElementById('valid_toyear').value)
{
alert('ERROR! beginning and ending dates of a period must be different');
return false;
}
else if(document.getElementById('valid_fromday').value>= document.getElementById('valid_today').value && document.getElementById('valid_frommo').value>= document.getElementById('valid_tomo').value && document.getElementById('valid_fromyear').value>= document.getElementById('valid_toyear').value)
{
alert('ERROR! beginning date of the period can not be later then ending date');
return false;
} ...
the select lists are created using PHP like this
//DATE ARRAYS
$day=array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31);
$mo=array(0,Jan,Feb,Mar,Apr,Mai,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
$thisyear=date("Y");
for($i=($thisyear-2);$i<($thisyear+5);$i++)
{
$year[]=$i;
}
...
From <select size="1" name="valid_fromday">
<?
for($i=1;$i<(count($day));$i++)
{
echo("<option value=\"$i\">$day[$i]</option>");
}
?>
</select> .... month year ext.
When the days or months between 1-9 selected as from date and
days and months greater 10 as to date, function alerts first date is later then second.
And when dates in the same month selected then it alerts dates must be different.
Why? and how can I solve the problem?
