Hi folks!
Probably just not enough coffee yet this morning but I cannot seem to figure
out why my validation script is not firing onsubmit, below is my script and
form code in question:
<script type=text/javascript>
function validateForm() {
var allOk = true;
var errorString = "The following are required fields:\n";
// require first name
if (!document.addnurse.First_Name.value) {
allOk = false;
errorString += "\n- First Name";
}
// require last name
if (!document.addnurse.Last_Name.value) {
allOk = false;
errorString += "\n- Last Name";
}
// require a division before processing the request
if (!document.addnurse.division.value) {
allOk = false;
errorString += "\n- Division";
}
// validate their email
var validEmail =
/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!validEmail.test(document.addnurse.email.value)) {
allOk = false;
errorString += "\n- Email Address";
}
// require building and room number
if (!document.addnurse.Degree.value) {
allOk = false;
errorString += "\n- Degree";
}
if (!allOk)
{
alert(errorString);
return false;
}
return allOk;
}
</script>
Form ----
<form action="index.cfm?fuseaction=admin.insertnursingmember" name="addnurse"
method="post" enctype="multipart/form-data" onsubmit="return
validateForm(this);">
<table style="background-color:##EFEFEF; padding:10px;
border-right:1px solid ##999999;
border-bottom:1px solid ##999999;"
align="center">
<tr>
<th colspan="2" align="center">#ButtonText#</th>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>First Name:</td>
<td><input type="text" name="First_Name" size="30"
maxlength="75" value="#First_Name#" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="Last_Name" size="30"
maxlength="75" value="#Last_Name#" /></td>
</tr>
<tr>
<td>Middle Inital:</td>
<td>
<input type="text" name="MI" size="1"
maxlength="5" value="#MI#" />
</td>
</tr>
<cfif SESSION.Auth.UserRole IS '2'>
<tr>
<td>Division:</td>
<td>
<select name="Division" size="1">
<option value="">Select
Division</option>
<option value="card">Cardiology</option>
<option value="diab">Diabetes</option>
<option value="DD">Digestive
Diseases</option>
<option
value="endo">Endocrinology</option>
<option value="gm">General Inernal
Medicine</option>
<option value="ger">Geriatrics</option>
<option
value="onc">Hematology/Oncology</option>
<option value="id">Infectious
Diseases</option>
<option value="neph">Nephrology</option>
<option value="pulm">Pulmonary</option>
<option
value="ri">Rheumatology/Immunology</option>
<option value="DOM-IS">DOM-IS</option>
</select>
</td>
</tr>
<cfelse>
<input type="hidden" name="division"
value="#SESSION.Auth.Division#" />
</cfif>
<tr>
<td>Degree:</td>
<td><input type="text" name="Degree" size="30"
maxlength="50" value="#Degree#" /></td>
</tr>
<tr>
<td>Title:</td>
<td><input type="text" name="Title" size="30"
maxlength="75" value="#Title#" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="Email" size="30"
maxlength="75" value="#Email#" /></td>
</tr>
<tr>
<td>Phone:</td>
<td><input type="text" name="Phone" size="30"
maxlength="75" value="#Phone#" /></td>
</tr>
<tr>
<td>Fax:</td>
<td>
<input type="text" name="Fax" size="30"
maxlength="75" value="#Fax#" />
<input type="hidden" name="id" value="#id#" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit"
name="submit_admin_personnel" value="#ButtonText#" />
</td>
</tr>
</table>
</form>
All of this wrapped in <cfoutput> and is used for adding and editing, hence the
form fields being populated with query data, if adding, they are populated with
empty strings.
TIA
Bob
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Upgrade to Adobe ColdFusion MX7
The most significant release in over 10 years. Upgrade & see new features.
http://www.adobe.com/products/coldfusion?sdid=RVJR
Archive:
http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:2856
Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15