I am having problem with this table. User has to input dates from January to December twice each month with execution date.
For instance, January 1 and execution date; January 30 and execution date.
Aug 12 and exec date.
My problem is if user enters a date with corresponding exec date, my javascript is still pending for other dates to enter. The user has the choice to fill all the fields of the table or leaving any date empty. But if a date is entered, it has to have an exec date.

Here is my code, please help! And thank you in advanced!

<HTML>
<HEAD>
<TITLE>html_setdates</TITLE>
<link rel="stylesheet" href="Docs/common.css" type="text/css"/>
</HEAD>

<SCRIPT LANGUAGE="JavaScript">
function return_home()
{
document.form1.action = "http:/#";
form1.submit();
}


function call_change()
{
inp = document.form1.TEST_LISTBOX.options.selectedIndex;
if (inp < 1)
{
alert("you must have selected a TEST before submitting your update. Please Try again!!!");
return;
}
inp = document.form1.SEL_YEAR.options.selectedIndex;
if (inp < 1)
{
alert("you must have selected a YEAR before submitting your update. Please Try again!!!");
return;
}

year_target = document.form1.SEL_YEAR.value;
var arr=[];
arr[0] = document.form1.JAN_SDATE.value; arr[1] = document.form1.EXE_JAN_SDATE.value;
arr[2] = document.form1.JAN_EDATE.value; arr[3] = document.form1.EXE_JAN_EDATE.value;
arr[4] = document.form1.FEB_SDATE.value; arr[5] = document.form1.EXE_FEB_SDATE.value;
arr[6] = document.form1.FEB_EDATE.value; arr[7] = document.form1.EXE_FEB_EDATE.value;
arr[8] = document.form1.MAR_SDATE.value; arr[9] = document.form1.EXE_MAR_SDATE.value;
arr[10] = document.form1.MAR_EDATE.value; arr[11] = document.form1.EXE_MAR_EDATE.value;
arr[12] = document.form1.APR_SDATE.value; arr[13] = document.form1.EXE_APR_SDATE.value;
arr[14] = document.form1.APR_EDATE.value; arr[15] = document.form1.EXE_APR_EDATE.value;
arr[16] = document.form1.MAY_SDATE.value; arr[17] = document.form1.EXE_MAY_SDATE.value;
arr[18] = document.form1.MAY_EDATE.value; arr[19] = document.form1.EXE_MAY_EDATE.value;
arr[20] = document.form1.JUN_SDATE.value; arr[21] = document.form1.EXE_JUN_SDATE.value;
arr[22] = document.form1.JUN_EDATE.value; arr[23] = document.form1.EXE_JUN_EDATE.value;
arr[24] = document.form1.JUL_SDATE.value; arr[25] = document.form1.EXE_JUL_SDATE.value;
arr[26] = document.form1.JUL_EDATE.value; arr[27] = document.form1.EXE_JUL_EDATE.value;
arr[28] = document.form1.AUG_SDATE.value; arr[29] = document.form1.EXE_AUG_SDATE.value;
arr[30] = document.form1.AUG_EDATE.value; arr[31] = document.form1.EXE_AUG_EDATE.value;
arr[32] = document.form1.SEP_SDATE.value; arr[33] = document.form1.EXE_SEP_SDATE.value;
arr[34] = document.form1.SEP_EDATE.value; arr[35] = document.form1.EXE_SEP_EDATE.value;
arr[36] = document.form1.OCT_SDATE.value; arr[37] = document.form1.EXE_OCT_SDATE.value;
arr[38] = document.form1.OCT_EDATE.value; arr[39] = document.form1.EXE_OCT_EDATE.value;
arr[40] = document.form1.NOV_SDATE.value; arr[41] = document.form1.EXE_NOV_SDATE.value;
arr[42] = document.form1.NOV_EDATE.value; arr[43] = document.form1.EXE_NOV_EDATE.value;
arr[44] = document.form1.DEC_SDATE.value; arr[45] = document.form1.EXE_DEC_SDATE.value;
arr[46] = document.form1.DEC_EDATE.value; arr[47] = document.form1.EXE_DEC_EDATE.value;
var test="G";
if ((arr[0]=="") || (arr[1]=="")){test='B';}
else {
test ='G';
if (datetest(arr[0], arr[1], year_target, test) == 'BAD') { return; }
}

if (((arr[2]=="") || (arr[3]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[2], arr[3], year_target, test) == 'BAD') { return; }
}

if (((arr[4]=="") || (arr[5]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[4], arr[5], year_target, test) == 'BAD') { return; }
}
if (((arr[6]=="") || (arr[7]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[6], arr[7], year_target, test) == 'BAD') { return; }
}
if (((arr[8]=="") || (arr[9]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[8], arr[9], year_target, test) == 'BAD') { return; }
}
if (((arr[10]=="") || (arr[11]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[10], arr[11], year_target, test) == 'BAD') { return; }
}
if (((arr[12]=="") || (arr[13]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[12], arr[13], year_target, test) == 'BAD') { return; }
}
if (((arr[14]=="") || (arr[15]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[14], arr[15], year_target, test) == 'BAD') { return; }
}
if (((arr[16]=="") || (arr[17]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[16], arr[17], year_target, test) == 'BAD') { return; }
}
if (((arr[18]=="") || (arr[19]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[18], arr[19], year_target, test) == 'BAD') { return; }
}
if (((arr[20]=="") || (arr[21]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[20], arr[21], year_target, test) == 'BAD') { return; }
}
if (((arr[22]=="") || (arr[23]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[22], arr[23], year_target, test) == 'BAD') { return; }
}
if (((arr[24]=="") || (arr[25]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[24], arr[25], year_target, test) == 'BAD') { return; }
}
if (((arr[26]=="") || (arr[27]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[26], arr[27], year_target, test) == 'BAD') { return; }
}
if (((arr[28]=="") || (arr[29]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[28], arr[29], year_target, test) == 'BAD') { return; }
}
if (((arr[30]=="") || (arr[31]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[30], arr[31], year_target, test) == 'BAD') { return; }
}
if (((arr[32]=="") || (arr[33]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[32], arr[33], year_target, test) == 'BAD') { return; }
}
if (((arr[34]=="") || (arr[35]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[34], arr[35], year_target, test) == 'BAD') { return; }
}
if (((arr[36]=="") || (arr[37]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[36], arr[37], year_target, test) == 'BAD') { return; }
}
if (((arr[38]=="") || (arr[39]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[38], arr[39], year_target, test) == 'BAD') { return; }
}
if (((arr[40]=="") || (arr[41]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[40], arr[41], year_target, test) == 'BAD') { return; }
}
if (((arr[42]=="") || (arr[43]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[42], arr[43], year_target, test) == 'BAD') { return; }
}
if (((arr[44]=="") || (arr[45]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[44], arr[45], year_target, test) == 'BAD') { return; }
}
if (((arr[46]=="") || (arr[47]=="")) && (test=="B")){test ='B';}
else {
test ='G';
if (datetest(arr[46], arr[47], year_target, test) == 'BAD') { return; }
}

if (test == "B") {alert ("You need to enter at least a date on the right and one on the left!!");return;}


document.form1.todo.value = 'MONCHG';
form1.submit();
}

function datetest(dat, dat_exe, year_target, test)
{
sss = strips(dat);
sss_exe = strips(dat_exe);
d = sss.split("-");

if(dat.match(/^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/))
{
yearTest = 'N';
if (d[0] == year_target) {yearTest = 'Y';}
if (yearTest == 'N'){
alert ("The year you selected is ("+year_target+") and the year you entered is ("+d[0]+"). Enter the date again!!!");
return ('BAD');
}
}
else{
alert("The date entered("+dat+") is invalid. The format is (YYYY-MM-DD). Try again!!!");
return('BAD');
}

if(!dat_exe.match(/^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/)){
alert("date format (" + dat_exe + ") is not good!");
return('BAD');
}
return('GOOD');
}

function call_dates() {
inp = document.form1.TEST_LISTBOX.options.selectedIndex;
if (inp < 1){
alert("you must have selected a TEST to retrieve before submitting your request. Please Try again!!!");
return;
}
inp = document.form1.SEL_YEAR.options.selectedIndex;
if (inp < 1)
{
alert("you must have selected a YEAR to retrieve before submitting your request. Please Try again!!!");
return;
}
document.form1.todo.value = 'PRICEDATE';
form1.submit(); }

function chg_refresh() {
document.form1.JAN_SDATE.value = ''; document.form1.EXE_JAN_SDATE.value = '';
document.form1.JAN_EDATE.value = ''; document.form1.EXE_JAN_EDATE.value = '';
document.form1.FEB_SDATE.value = ''; document.form1.EXE_FEB_SDATE.value = '';
document.form1.FEB_EDATE.value = ''; document.form1.EXE_FEB_EDATE.value = '';
document.form1.MAR_SDATE.value = ''; document.form1.EXE_MAR_SDATE.value = '';
document.form1.MAR_EDATE.value = ''; document.form1.EXE_MAR_EDATE.value = '';
document.form1.APR_SDATE.value = ''; document.form1.EXE_APR_SDATE.value = '';
document.form1.APR_EDATE.value = ''; document.form1.EXE_APR_EDATE.value = '';
document.form1.MAY_SDATE.value = ''; document.form1.EXE_MAY_SDATE.value = '';
document.form1.MAY_EDATE.value = ''; document.form1.EXE_MAY_EDATE.value = '';
document.form1.JUN_SDATE.value = ''; document.form1.EXE_JUN_SDATE.value = '';
document.form1.JUN_EDATE.value = ''; document.form1.EXE_JUN_EDATE.value = '';
document.form1.JUL_SDATE.value = ''; document.form1.EXE_JUL_SDATE.value = '';
document.form1.JUL_EDATE.value = ''; document.form1.EXE_JUL_EDATE.value = '';
document.form1.AUG_SDATE.value = ''; document.form1.EXE_AUG_SDATE.value = '';
document.form1.AUG_EDATE.value = ''; document.form1.EXE_AUG_EDATE.value = '';
document.form1.SEP_SDATE.value = ''; document.form1.EXE_SEP_SDATE.value = '';
document.form1.SEP_EDATE.value = ''; document.form1.EXE_SEP_EDATE.value = '';
document.form1.OCT_SDATE.value = ''; document.form1.EXE_OCT_SDATE.value = '';
document.form1.OCT_EDATE.value = ''; document.form1.EXE_OCT_EDATE.value = '';
document.form1.NOV_SDATE.value = ''; document.form1.EXE_NOV_SDATE.value = '';
document.form1.NOV_EDATE.value = ''; document.form1.EXE_NOV_EDATE.value = '';
document.form1.DEC_SDATE.value = ''; document.form1.EXE_DEC_SDATE.value = '';
document.form1.DEC_EDATE.value = ''; document.form1.EXE_DEC_EDATE.value = '';

document.form1.USER.value = '';
document.form1.UPDATE.value = '';
document.form1.CHG_WARN.value = '====>';
}

function strips(dat) {
while (dat.substring(0,1) == ' ') dat = dat.substring(1);
while (dat.substring(dat.length-1,dat.length) == ' ') dat = dat.substring(0,dat.length-1);
return(dat); }

</SCRIPT>
<BODY TEXT="BLACK" LINK="BLUE" VLINK="GREEN" ALINK="PURPLE" BGCOLOR="#FOF8FF" $bodytimer ">
<FORM NAME="form1" ACTION="http:/www/cgi-bin/test.pl" METHOD="post">
<INPUT TYPE="hidden" Name="passwd" Value="$password">
<INPUT TYPE="hidden" Name="user" Value="$userid">
<INPUT TYPE="hidden" Name="todo" Value="$mytodo">
<INPUT TYPE="hidden" Name="profile" Value="WRT">
<INPUT TYPE="hidden" Name="loader" Value="$myloader">

<table width="100%"><TR>
<TD align="left" width="15%"><A HREF="#"><B>Home Page</B></A></TD>
<TD align="CENTER" width="70%"><h1>Testing Date Menu</h1></TD>
<TD align="right" width="15%"><INPUT TYPE="submit" class="send_button" Value="Return"></td></tr>
</table>

<table width="100%">
<tr>
<td>Select Test Name:
<select NAME="TEST_LISTBOX" size="1" onchange="chg_refresh()">
<option></option>
<option value = "test1">test1</option>
<option value = "test2">test2</option>
<option value = "test3">test3</option>
</select>
&nbsp; &nbsp; &nbsp;Year:
<select size="1" NAME="SEL_YEAR" onchange="chg_refresh()">
<option></option>
<option $y[2] value = "2012">2012</option>
<option $y[3] value = "2013">2013</option>
<option $y[4] value = "2014">2014</option>
</select>
</td>
<td align="Right">
<INPUT type="TEXT" Name="CHG_WARN" SIZE="6" READONLY style="border: 0px solid #000000;">
<INPUT TYPE="button" class="send_button" value="Retrieve Selection Dates and test" ONCLICK="call_dates()">
</td>
</tr>
</table>
<table width="100%">
<tr>
<td>Last Modified User<INPUT TYPE="text" Name="USER" SIZE="30" MAXLENGTH="33" READONLY></td>
<td>Last Update<INPUT TYPE="text" Name="UPDATE" SIZE="30" MAXLENGTH="33" READONLY></td>
<td align="right">&nbsp;</td>
</tr></table>
<hr style="color:#6b9ef1;border:1px dotted;" width="70%">
<br /> <center><INPUT TYPE="button" class="send_button" id="submit_upd1" value="Submit Update" ONCLICK="call_change()"></center><br />

<table width="100%" BORDER BGCOLOR="LIGHTBLUE">
<TR>
<TD><B>
FORMAT(<B><FONT COLOR="BLUE">YYYY-MM-DD</FONT></B>) Enter the Monthly Start and End Dates with the date to be Executed.
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;

</B></td>
</tr></table>
<table WIDTH="100%" BORDER id="myTable">
<tr>
<th>Month</th><th>Start/End Dates</th><th>Execution Date</th>
</tr>
<tr class="datacell" id="row1">
<td>January Start</td><td><INPUT TYPE="text" Name="JAN_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_JAN_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row2">
<td>January End</td><td><INPUT TYPE="text" Name="JAN_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_JAN_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row3">
<td>February Start</td><td><INPUT TYPE="text" Name="FEB_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_FEB_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row4">
<td>February End</td><td><INPUT TYPE="text" Name="FEB_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_FEB_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row5">
<td>March Start</td><td><INPUT TYPE="text" Name="MAR_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_MAR_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row6">
<td>March End</td><td><INPUT TYPE="text" Name="MAR_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_MAR_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row7">
<td>April Start</td><td><INPUT TYPE="text" Name="APR_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_APR_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row8">
<td>April End</td><td><INPUT TYPE="text" Name="APR_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_APR_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row9">
<td>May Start</td><td><INPUT TYPE="text" Name="MAY_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_MAY_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row10">
<td>May End</td><td><INPUT TYPE="text" Name="MAY_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_MAY_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row11">
<td>June Start</td><td><INPUT TYPE="text" Name="JUN_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_JUN_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row12">
<td>June End</td><td><INPUT TYPE="text" Name="JUN_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_JUN_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row13">
<td>July Start</td><td><INPUT TYPE="text" Name="JUL_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_JUL_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row14">
<td>July End</td><td><INPUT TYPE="text" Name="JUL_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_JUL_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row15">
<td>August Start</td><td><INPUT TYPE="text" Name="AUG_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_AUG_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row16">
<td>August End</td><td><INPUT TYPE="text" Name="AUG_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_AUG_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row17">
<td>September Start</td><td><INPUT TYPE="text" Name="SEP_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_SEP_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row18">
<td>September End</td><td><INPUT TYPE="text" Name="SEP_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_SEP_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row19">
<td>October Start</td><td><INPUT TYPE="text" Name="OCT_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_OCT_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row20">
<td>October End</td><td><INPUT TYPE="text" Name="OCT_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_OCT_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row21">
<td>November Start</td><td><INPUT TYPE="text" Name="NOV_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_NOV_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row22">
<td>November End</td><td><INPUT TYPE="text" Name="NOV_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_NOV_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr class="datacell" id="row23">
<td>December Start</td><td><INPUT TYPE="text" Name="DEC_SDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_DEC_SDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
<tr id="row24">
<td>December End</td><td><INPUT TYPE="text" Name="DEC_EDATE" SIZE="12" MAXLENGTH="10"></td>
<td><INPUT TYPE="text" Name="EXE_DEC_EDATE" SIZE="12" MAXLENGTH="10"></td>
</tr>
</table>

<br />
&nbsp; &nbsp; &nbsp; &nbsp;
<center><INPUT TYPE="button" class="send_button" id="submit_upd2" value="Submit Update" ONCLICK="call_change()"></center>
</FORM>
<center><font size="+2" color="blue">Page is under construction!!!</font></br>
<font size="2" color="blue">Last modified on: <script>document.write(document.lastModified);</script></font>
</center>

</BODY>
</HTML>