Hello,
I have a question about how to us an Image button to validate a form and then submit the data once the validation is successful. I seem to be able to make it work with a standard button, but I try the image it just blows right by the validation.
Any ideas?
Here is the code that I am using:
I have a question about how to us an Image button to validate a form and then submit the data once the validation is successful. I seem to be able to make it work with a standard button, but I try the image it just blows right by the validation.
Any ideas?
Here is the code that I am using:
Code:
<html>
<head>
<title>Validation</title>
<script language="javascript" type="text/javascript" >
<!-- Begin
function Require(obForm,szFields)
{
var fields = szFields.split(",")
var szMissing= new Array();
for (x=0;x<fields.length;x++) {
if (obForm.elements[fields[x]].value.length==0) {
szMissing[szMissing.length]=new String(fields[x]);
}
}
if (szMissing.length) {
alert("The field"+((szMissing.length>1)?"s ":" ")+szMissing.join(",")+" must be filled in first");
return false
}
return true;
}
// end-->
</script>
</head>
<body onLoad="document.RefiOrderForm.ReferenceNumber.focus();">
<form name="RefiOrderForm" method="post" action="[URL unfurl="true"]http://www.msn.com"[/URL] onSubmit="return Require(this,'ReferenceNumber')">
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="5"></td>
</tr>
<tr>
<td width="141" height="24" class="Titles"><span class="bullets">*</span>Reference Number:</td>
<td width="619" colspan="4" ><input tabindex="1" name="ReferenceNumber" type="text" class="formfills" id="RefNumber" size="60" maxlength="60" ></td>
</tr>
<tr>
<td height="24" class="Titles"> </td>
<td colspan="4" > </td>
</tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="26" colspan="6" class="Headers"> Subject Property</td>
</tr>
<tr>
<td width="133" height="26" class="Titles"><span class="bullets">*</span>Address:</td>
<td width="388" ><input tabindex="11" class="formfills" name="SubjectAddress" type="text" id="SubjectAddress" size="60" maxlength="60" ></td>
<td width="104" class="Titles">Property Type:</td>
<td width="135" colspan="3"><select tabindex="17" name="PropType" class="formfills" id="PropType" >
<option value="UNKNOWN" selected>Please Select One
<option value="SFR">Single Family
<option value="CONDO">Condo
<option value="COMMERCIAL">Commercial
<option value="INDUSTRIAL">Industrial
<option value="VACANT">Vacant
<option value="UNKNOWN">Unknown
</select></td>
</tr>
<tr>
<td height="26" class="Titles"><span class="bullets">*</span>City,State,Zip:</td>
<td colspan="5" ><input class="formfills" tabindex="12" name="SubjectCity" type="text" id="SubjectCity" size="37" maxlength="36" >
<input class="formfills" tabindex="13" name="SubjectState" type="text" id="SubjectState" size="4" maxlength="2" >
<input class="formfills" tabindex="14" name="SubjectZip" type="text" id="SubjectZip" size="10" maxlength="10" > </td>
</tr>
<tr>
<td height="26" class="Titles">County:</td>
<td colspan="5" ><input name="SubjectPropCounty" type="text" class="formfills" id="SubjectPropCounty" tabindex="15" size="60" maxlength="60"></td>
</tr>
<tr>
<td height="26" class="Titles">APN/Tax Parcel#(s):</td>
<td colspan="5" ><input class="formfills" tabindex="16" name="Apn" type="text" id="Apn" size="60" maxlength="30" ></td>
</tr>
<tr>
<td height="29" colspan="6"><hr color="#000000" noshade size="3"></td>
</tr>
</table>
<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25" colspan="6" class="Headers"> Borrower Information</td>
</tr>
<tr>
<td width="133" height="25" class="Titles"><span class="bullets">*</span>Borrower Name:</td>
<td colspan="5"><input tabindex="17" name="BorrowerName" type="text" class="formfills" id="BorrowerName" size="60" maxlength="60" ></td>
</tr>
<tr>
<td height="25" class="Titles">Work Phone:</td>
<td width="118"><input tabindex="18" name="BorrowerWorkPhone" type="text" class="formfills" id="BorrowerWorkPhone" size="17" maxlength="17" ></td>
<td width="119" class="Titles">Social Security:</td>
<td width="390" colspan="3"><input tabindex="19" name="BorrowerSS" type="text" class="formfills" id="BorrowerSS" size="20" maxlength="20" ></td>
</tr>
<tr>
<td height="25" class="Titles">Co-Borrower Name:</td>
<td colspan="5"><input tabindex="20" name="CoBorrowerName" type="text" class="formfills" id="CoBorrowerName" size="60" maxlength="60" ></td>
</tr>
<tr>
<td height="25" class="Titles">Work Phone:</td>
<td><input tabindex="21" name="CoBorrowerWorkPhone" type="text" class="formfills" id="CoBorrowerWorkPhone" size="17" maxlength="17" ></td>
<td class="Titles">Social Security:</td>
<td colspan="3"><input tabindex="22" name="CoBorrowerSS" type="text" class="formfills" id="CoBorrowerSS" size="20" maxlength="20" ></td>
</tr>
</table>
<table width="760" height="90" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td width="721" ><input name="" type="submit">
<a href="javascript:document.RefiOrderForm.submit()" onClick=""><img src="../images/SubmitOrderButton.gif" border="0" alt="Submit Order"></a>
</td>
</tr>
</table>
</form>
</body>
</html>