Can anyone tell me why this is not working. None of the msgbox's come up so the entire function isn't firing with the forms onSubmit. I have this script in a few other pages and it works fine.
And here is the select case that builds that form
Code:
<script language="vbscript">
Function frm_onSubmit()
Dim sMsg, nErr
'MsgBox's are for testing
If document.frmEmpInfo.txtFN.Value = "" Then
sMsg = sMsg & "First name is required." & VbCrLf
MsgBox sMsg
nErr = 1
End If
If document.frmEmpInfo.txtLN.Value = "" Then
sMsg = sMsg & "Last name is required." & VbCrLf
MsgBox sMsg
nErr = 1
End If
If document.frmEmpInfo.cboDept.Value = "" Then
sMsg = sMsg & "Department is required." & VbCrLf
MsgBox sMsg
nErr = 1
End If
If document.frmEmpInfo.txtTitle.Value = "" Then
sMsg = sMsg & "Title is required." & VbCrLf
MsgBox sMsg
nErr = 1
End If
If document.frmEmpInfo.txtExt.Value = "" Then
sMsg = sMsg & "Extension is required." & VbCrLf
MsgBox sMsg
nErr = 1
End If
If len(document.frmEmpInfo.txtExt.Value <> 4 Then
sMsg = sMsg & "Extension must be 4 digits." & VbCrLf
MsgBox sMsg
nErr = 1
End If
If Not isnumeric(document.frmEmpInfo.txtTitle.Value) Then
sMsg = sMsg & "Extension must be a number." & VbCrLf
MsgBox sMsg
nErr = 1
End If
If document.frmEmpInfo.cboCube.Value = "" Then
sMsg = sMsg & "Cube is required." & VbCrLf
MsgBox sMsg
nErr = 1
End If
If len(document.frmEmpInfo.txtUserId.Value) > 8 Then
sMsg = sMsg & "User ID's must be 8 or less characters." & VbCrLf
MsgBox sMsg
nErr = 1
End If
Select Case nErr
Case 1
MsgBox sMsg,vbOKOnly,"Incorrect Information"
window.event.returnValue = False
Case Else
MsgBox "No errors found"
window.event.returnValue = True
End Select
End Function
</script>
And here is the select case that builds that form
Code:
<%Select Case request.querystring("CMD")
Case "Add"%>
<br>
<form method="get" action="Emp_Information.asp" name="frmEmpInfo" onsubmit="frm_onSubmit();">
<table width="100%" style="background: navy; color: white; font-size: 10pt; font-weight: bold">
<tr><td align="center"><font color="white">Add Employee</font></td></tr>
</table>
<table class="TDBody" border="4" cellpadding="1" cellspacing="1" align="center">
<tr><td align="right">First Name: </td><td><input type="text" maxlength="25" size="25" name="txtFN"></td></tr>
<tr><td align="right">Last Name: </td><td><input type="text" maxlength="25" size="25" name="txtLN"></td></tr>
<tr><td align="right">Department: </td><td><select name="cboDept">
<option value=""></option>
<%sSQL = "SELECT * FROM ztblDept ORDER BY Description"
Set RS = Conn.Execute(sSQL,,1)
Do While Not RS.EOF%>
<option value="<%=RS.Fields("DeptCode")%>"><%=RS.Fields("Description")%></option>
<%RS.MoveNext
Loop
RS.Close%>
</select></td></tr>
<tr><td align="right">Title: </td><td><input type="text" maxlength="50" size="25" name="txtTitle"></td></tr>
<tr><td align="right">Extension: </td><td><input type="text" maxlength="4" size="4" name="txtExt"></td></tr>
<tr><td align="right">Cube: </td><td><select name="cboCube">
<option value=""SELECTED></option>
<%sSQL = "SELECT * FROM ztblCubes"
Set RS = Conn.Execute(sSQL,,1)
Do While Not RS.EOF%>
<option value="<%=RS.Fields("CubeNumber")%>"><%=RS.Fields("CubeNumber")%></option>
<%RS.MoveNext
Loop
RS.Close%>
</select></td></tr>
<tr><td align="right">User ID: </td><td><input type="text" maxlength="8" size="8" name="txtUserID"></td></tr>
<tr><td align="right">Pic Name: </td><td><input type="text" maxlength="15" size="15" name="txtPicName"></td></tr>
<tr><td align="right">Manager: </td><td><select name="cboManager">
<option value="0"SELECTED>NO</option>
<option value="1">YES</option>
</select></td></tr>
<tr><td align="right">Supervisor: </td><td><select name="cboSupervisor">
<option value="0"SELECTED>NO</option>
<option value="1">YES</option>
</select></td></tr>
<tr><td align="right">New Hire: </td><td><select name="cboNewHire">
<option value="0"SELECTED>NO</option>
<option value="1">YES</option>
</select></td></tr>
<tr><td colspan="2" align="center"><input type="submit" name="CMD" value="Submit"></td></tr>
</table>
</form>
<%case else%>
etc.....