Hi,
I am a javascript beginner. I have problem making fields mandatory in the following form.
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=windows-1252″>
<title>Form submission</title>
</head>
<body>
<table id=”table9″ cellSpacing=”0″ cellPadding=”0″ width=”940″ border=”0″ valign=”TOP”>
<tr>
<td>
<form action=”” METHOD= POST>
<font size=+1 face=”arial”>Form Details</font>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 bgColor=”#cccccc” width=”782″ id=”table16″>
<tr>
<td ALIGN=LEFT width=”226″>Request Date:</td>
<td width=”215″><input NAME=”reqdate” size=”23″ MAXLENGTH=55></td>
<td width=”172″>Type:</td>
<td ALIGN=LEFT><select NAME=”type”>
<option value=”business” SELECTED>business</option>
<option value=”vacation”>vacation</option>
</td>
</tr>
<tr>
<td ALIGN=LEFT width=”226″>Group:</td>
<td width=”215″><select NAME=”group”>
<option value=”group1″ SELECTED>group1</option>
<option value=”group2″>group2</option>
</td>
<td ALIGN=LEFT>No. of People:</td>
<td><input NAME=”people” SIZE=9 MAXLENGTH=55 ></td>
</tr>
<tr>
<td ALIGN=LEFT width=”226″>Emp ID:</td>
<td width=”215″><input NAME=”empid” SIZE=25 MAXLENGTH=55 ></td>
<td ALIGN=LEFT>Emp Names:</td>
<td><input NAME=”empname” SIZE=17 MAXLENGTH=55 ></td>
</tr>
<tr>
<td ALIGN=LEFT width=”226″>Place Name:</td>
<td width=”215″><input NAME=”placename” SIZE=25 MAXLENGTH=55 ></td>
<td ALIGN=LEFT>Code Number:</td>
<td><input NAME=”codeno” SIZE=17 MAXLENGTH=55 ></td>
</tr>
<tr>
<td ALIGN=LEFT width=”226″>Target Date for Travel:</td>
<td width=”215″><input NAME=”targetdate” SIZE=25 MAXLENGTH=55 ></td>
<td ALIGN=LEFT>Duration:</td>
<td><input NAME=”duration” SIZE=17 MAXLENGTH=55 ></td>
<tr>
<td ALIGN=LEFT width=”226″> </td>
<td width=”215″> </td>
</tr>
</table>
<p><b>If business then provide the
details below.</b>
<br>
</p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 bgColor=”#cccccc” id=”table17″ width=”779″ >
<tr>
<td ALIGN=LEFT width=”224″>Agency Name:</td>
<td width=”216″><input NAME=”agencyName” SIZE=23 MAXLENGTH=75 ></td>
</tr>
<tr>
<td ALIGN=LEFT width=”224″>Address:</td>
<td width=”216″><input NAME=”Address” SIZE=23 MAXLENGTH=100 ></td>
</tr>
<tr>
<td ALIGN=LEFT width=”224″>Contact Name:</td>
<td width=”216″><input NAME=”contactname” SIZE=23 MAXLENGTH=55 ></td>
<td ALIGN=LEFT width=”172″>Telephone No:</td>
<td width=”485″><input NAME=”teleno” SIZE=17 MAXLENGTH=30 ></td>
</tr>
<tr>
<td ALIGN=LEFT width=”224″>Email:</td>
<td width=”216″><input NAME=”email” SIZE=23 MAXLENGTH=55 ></td>
</tr>
</table>
<p>
<font face=”Times New Roman”><b>Justification</b> (for approval)</font></p>
</p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 bgColor=”#cccccc” id=”table18″ width=”779″ >
<tr>
<td>
<textarea name=”justification” rows=5 wrap=virtual cols=74 default=”Null”></textarea></td>
</tr>
</table>
<p><b><span style=”font-size: 12.0pt; font-family: Times New Roman”>Financial Details
required</span></b></p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 bgColor=”#cccccc” id=”table19″ width=”782″ >
<tr>
<td ALIGN=LEFT width=”226″>Travel type:</td>
<td width=”215″><select NAME=”traveltype”>
<option value=”home” SELECTED>Home</option>
<option value=”away”>Away</option>
</td>
<td ALIGN=LEFT width=”171″>Travel cost:</td>
<td width=”489″><input NAME=”cost” SIZE=17 MAXLENGTH=30 ></td>
</tr>
<tr>
<td ALIGN=LEFT width=”227″>Anticipated expenses:</td>
<td width=”213″><input NAME=”expenses” SIZE=23 MAXLENGTH=100 ></td>
</tr>
<tr>
<td ALIGN=LEFT width=”227″> </td>
<td width=”213″> </td>
</tr>
</table>
<p class=”MsoNormal”><b>Approvals obtained to-date </b></p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 bgColor=”#cccccc” id=”table20″ width=”780″ >
<tr>
<td ALIGN=LEFT width=”222″>CM approval (enter name):</td>
<td width=”219″><input NAME=”cmname” SIZE=23 MAXLENGTH=75 ></td>
<td ALIGN=LEFT width=”173″>DM approval (enter name):</td>
<td width=”505″><input NAME=”dmname” SIZE=17 MAXLENGTH=30 ></td>
</tr>
<tr>
<td ALIGN=LEFT width=”222″> </td>
<td width=”219″> </td>
</tr>
<tr>
<td ALIGN=LEFT width=”222″> </td>
<td width=”219″> </td>
</tr>
<tr>
<td ALIGN=LEFT width=”222″> </td>
<td width=”219″> <input type=submit value=Submit> <INPUT type=reset value=”Clear Form”></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
In the above form, ‘Request date’ is mandatory.
If ‘Business’ is selected in the field ‘Type’, then ‘Travel cost’, ‘Anticipated expenses’ are mandatory. If ‘Vacation’ is selected, ‘Travel Cost’, ‘Anticipated expenses’ are optional.
‘Empid’ is mandatory and should have same no. of entries as ‘No of People’.
If ‘group1’ is selected in category ‘Group’, ‘Agency Name’, ‘Address’, ‘Telephone no’ are mandatory.
‘Travel type’, ‘CM approval’ and ‘DM approval’ are mandaory. Textarea ‘Justification’ is also mandatory.
Could anyone help me in making this work please!
Thanks
Bhavya