The general js validation I do for select boxes are as under
Code: Select all
<script language="JavaScript">
function validSelect(formField,fieldLabel)
{
var result = true;
if (formField.selectedIndex == 0)
{
alert('Please enter a value for the "' + fieldLabel +'" field.');
formField.focus();
result = false;
}
return result;
}
unction validateForm(theForm)
{
// Start ------->
if (!validSelect(theForm.fieldname,"label"))
return false;
// <--------- End
return true;
}
</script>Code: Select all
<form enctype="multipart/form-data" action="classifieds.php?action=addad3&in=4" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="30%" align="right"><strong>image to upload:</strong></td>
<td width="80%"> <input name="imagefile[]" id="imagefile[]" type="file" class="txtbox" size="50"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="30%" align="right"><strong>image to upload:</strong></td>
<td width="80%"> <input name="imagefile[]" id="imagefile[]" type="file" class="txtbox" size="50"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="30%" align="right"><strong>image to upload:</strong></td>
<td width="80%"> <input name="imagefile[]" id="imagefile[]" type="file" class="txtbox" size="50"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td width="30%" align="right"><strong>image to upload:</strong></td>
<td width="80%"> <input name="imagefile[]" id="imagefile[]" type="file" class="txtbox" size="50"></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr bgcolor="#CCCCCC">
<td nowrap class="text"><a href="classifieds.php?action=home" class="text">< cancel</a></td>
<td class="text" align="right">
<input class='btn' onMouseOver="this.className='btn btnhov'" onMouseOut="this.className='btn'" type="submit" name="submit" value="upload and finish">
</td>
</tr>
</table></td>
</form>