Guest_imported
New member
- Jan 1, 1970
- 0
Hi guys,
I have an ASP application. I'd like the program to display a message if someone has not entered information in the required fields. The vbscript code does not work. I simply do not get any message display. Here is the code:
<%@ LANGUAGE = "VBSCRIPT"%>
<%OPTION EXPLICIT%>
<html>
<head>
<title>Directory-Panama</title>
</head>
<body bgcolor="#FFFFFF" background="background.gif" text="#000066">
<!--#INCLUDE file = "adovbs.inc"-->
<!--#INCLUDE file = "dbconx.asp"-->
<form action="addpersonexe.asp" name=addpersonform method="post">
<table width="719" border="0" cellspacing="2" cellpadding="0" height="404" align="left">
<tr>
<td valign="top" width="148" height="117"><img src="spacer.gif" width="147" height="11"></td>
<td height="117" align="left" valign="top" colspan="5" width="550"><font size="5" face="Times New Roman, Times, serif" color="#990000"><b><img src="title.gif" width="300" height="63"></b></font>
<font face="Arial, Helvetica, sans-serif" color ="#CC0000" size="2"><br>
<b>Add a Person</b><hr size="0" noshade></font>
<p><font size="2" face="Times New Roman, Times, serif" color="#000080">Fill
out the fields below to enter your information in the database. The
</font><font size="2" face="Times New Roman, Times, serif" color="#FF0000"> *
</font><font size="2" face="Times New Roman, Times, serif" color="#000080"> indicates required information.<br>
<br>
</font></td>
</tr>
<tr>
<td width="148" height="40"> </td>
<td cellspace="0" valign="top" align="left" height="40" width="257"><b>Last
Name <font color="#FF0000">*</font><br>
<input name="lname" size="20" >
</b></td>
<td cellspace="0" valign="top" align="left" height="40" width="9"> </td>
<td width="132"><b>First Name <font color="#FF0000">*</font> <br>
<input name="fname" size="15" >
</b>
<td height="40" width="46"><b>MI</b> <br>
<input name="mi" size="1">
</td>
<td height="40" align="left" valign="top" width="90">
</td>
<td width="7">
<br>
</tr>
<tr>
<td width="148" height="36"> </td>
<td cellspace="0" valign="top" align="left" height="36" width="257"><b> Street
Address<br>
<input name="streetname" size="25">
</b></td>
<td cellspace="0" valign="top" align="left" height="36" width="9"> </td>
<td width="132" cellspace="0" valign="top" align="left" height="36"><b>City<br>
<input name="city" size="15">
</b></td>
<td width="46" valign="top" align="left"><b>State</b> <br>
<input name="state" size="1">
</td>
<td align="left" cellspacing="0" valign="top" height="36" width="90"><b>Zip
Code<br>
<input name="zipcode" size="5">
</b></td>
</tr>
<tr>
<td width="148" height="52"> </td>
<td cellspace="0" valign="top" align="left" height="52" width="257" nowrap><b>Postal
address </b><font size="2"> <font size="1"> </font></font><b><br>
<input name="postal_address" size="30">
<br>
</b></td>
<td cellspace="0" valign="top" align="left" height="52" width="9" nowrap><b>
</b></td>
<td cellspace="0" valign="top" align="left" height="52" colspan="3" width="276"><b>Country
<font color="#FF0000">*</font></b><br>
<%
Dim myRS, country
Response.Write "<select name = 'country'>"
Response.Write "<option value=''>Choose a Country</option>"
Set myRS = Server.CreateObject("ADODB.Recordset"
myRS.Open "SELECT * FROM country order by country", myConn
While Not myRS.EOF
country = myRS("country"
Response.Write "<option value = '" & country & "'>"
Response.Write country & "</option>"
myRS.MoveNext
Wend
Response.Write "</select>"
myRS.Close
%>
</td>
</tr>
<tr>
<td width="148" height="49"> </td>
<td width="257" cellspace="0" valign="top" align="left" height="49"><b>Primary
telephone number<br>
<input name="telephone1">
</b></td>
<td cellspace="0" valign="top" align="left" height="49" width="9">
<p align="left"> </p>
</td>
<td cellspace="0" valign="top" align="left" height="49" colspan="3" width="276"><b>Alternate
telephone number<br>
<input name="telephone2">
</b></td>
</tr>
<tr>
<td width="148"> </td>
<td width="257" align="left" valign="top"><b>Primary email <font color="#FF0000">*</font><br>
<input name="email1">
</b>
<td width="9" align="left" valign="top">
<td colspan="3" align="left" valign="top" width="276"><b>Alternate email<br>
<input name="email2">
</b>
<tr>
<td width="148"> </td>
<td colspan="5" align="left" valign="top" width="550"><b><br>
Website</b><br>
<input name="website" size="35">
<tr>
<td width="148"> </td>
<td width="257" align="left" valign="top"><b>
Type of Business:<font color="#FF0000">*</font></b><br>
<%
Dim btype
Response.Write "<select name = 'type'>"
Response.Write "<option value=''>Choose a Business Category</option>"
Set myRS = Server.CreateObject("ADODB.Recordset"
myRS.Open "SELECT * FROM worktype order by type", myConn
While Not myRS.EOF
btype = myRS("type"
Response.Write "<option value = '" & btype & "'>"
Response.Write btype & "</option>"
myRS.MoveNext
Wend
Response.Write "</select>"
myRS.Close
Set myRS= Nothing
myconn.Close
Set myConn= Nothing
%>
</td>
<td width="9" align="left" valign="top"> </td>
<td colspan="4" align="left" valign="top" width="287"><b>
Describe your type of business:<br>
<textarea name="description" cols="20" rows="1"></textarea>
</b>
</tr>
<tr>
<td width="148"> </td>
<td width="257" align="right" valign="top"> <br>
<input type="submit" value="Add entry" name="Submit">
<td width="9" align="right" valign="top">
<td colspan="4" align="left" valign="top" width="287"> <br>
<input type="reset" value="Clear">
</tr>
<script language=VBScript>
Sub btnSubmit_OnClick()
If Len (frmaddpersonform.txtlname.value) = 0 then
Alert "You must enter your last name"
addpersonform.lname.focus
Exit sub
ElseIf Len (frmaddpersonform.txtfname.value) = 0 then
Alert "You must enter your first name"
addpersonform.fname.focus
Exit Sub
End if
Call frmaddpersonform.submit()
end sub
</script>
<tr>
<td width="148"> </td>
<td colspan="6" align="left" valign="top" width="561">
<hr noshade size="0" align="center">
<font size="1"><a href="index.html">Home</a>|<a href="searchpersonform.asp">People Search</a>| Organization/Business Search |<b>Add
personal record</b>| Add business/organization record</font> <br>
<hr size="0" noshade align="center">
<a href="mailto:itzel@mail.utexas.edu"><font size="2">itzel@mail.utexas.edu</font></a><font size="2"><br>
<font size="1">University of Texas<br>
Graduate School of Library and Information Science</font></font></td>
</tr>
</table>
</cfform>
</body>
</html>
</script>
I have an ASP application. I'd like the program to display a message if someone has not entered information in the required fields. The vbscript code does not work. I simply do not get any message display. Here is the code:
<%@ LANGUAGE = "VBSCRIPT"%>
<%OPTION EXPLICIT%>
<html>
<head>
<title>Directory-Panama</title>
</head>
<body bgcolor="#FFFFFF" background="background.gif" text="#000066">
<!--#INCLUDE file = "adovbs.inc"-->
<!--#INCLUDE file = "dbconx.asp"-->
<form action="addpersonexe.asp" name=addpersonform method="post">
<table width="719" border="0" cellspacing="2" cellpadding="0" height="404" align="left">
<tr>
<td valign="top" width="148" height="117"><img src="spacer.gif" width="147" height="11"></td>
<td height="117" align="left" valign="top" colspan="5" width="550"><font size="5" face="Times New Roman, Times, serif" color="#990000"><b><img src="title.gif" width="300" height="63"></b></font>
<font face="Arial, Helvetica, sans-serif" color ="#CC0000" size="2"><br>
<b>Add a Person</b><hr size="0" noshade></font>
<p><font size="2" face="Times New Roman, Times, serif" color="#000080">Fill
out the fields below to enter your information in the database. The
</font><font size="2" face="Times New Roman, Times, serif" color="#FF0000"> *
</font><font size="2" face="Times New Roman, Times, serif" color="#000080"> indicates required information.<br>
<br>
</font></td>
</tr>
<tr>
<td width="148" height="40"> </td>
<td cellspace="0" valign="top" align="left" height="40" width="257"><b>Last
Name <font color="#FF0000">*</font><br>
<input name="lname" size="20" >
</b></td>
<td cellspace="0" valign="top" align="left" height="40" width="9"> </td>
<td width="132"><b>First Name <font color="#FF0000">*</font> <br>
<input name="fname" size="15" >
</b>
<td height="40" width="46"><b>MI</b> <br>
<input name="mi" size="1">
</td>
<td height="40" align="left" valign="top" width="90">
</td>
<td width="7">
<br>
</tr>
<tr>
<td width="148" height="36"> </td>
<td cellspace="0" valign="top" align="left" height="36" width="257"><b> Street
Address<br>
<input name="streetname" size="25">
</b></td>
<td cellspace="0" valign="top" align="left" height="36" width="9"> </td>
<td width="132" cellspace="0" valign="top" align="left" height="36"><b>City<br>
<input name="city" size="15">
</b></td>
<td width="46" valign="top" align="left"><b>State</b> <br>
<input name="state" size="1">
</td>
<td align="left" cellspacing="0" valign="top" height="36" width="90"><b>Zip
Code<br>
<input name="zipcode" size="5">
</b></td>
</tr>
<tr>
<td width="148" height="52"> </td>
<td cellspace="0" valign="top" align="left" height="52" width="257" nowrap><b>Postal
address </b><font size="2"> <font size="1"> </font></font><b><br>
<input name="postal_address" size="30">
<br>
</b></td>
<td cellspace="0" valign="top" align="left" height="52" width="9" nowrap><b>
</b></td>
<td cellspace="0" valign="top" align="left" height="52" colspan="3" width="276"><b>Country
<font color="#FF0000">*</font></b><br>
<%
Dim myRS, country
Response.Write "<select name = 'country'>"
Response.Write "<option value=''>Choose a Country</option>"
Set myRS = Server.CreateObject("ADODB.Recordset"
myRS.Open "SELECT * FROM country order by country", myConn
While Not myRS.EOF
country = myRS("country"
Response.Write "<option value = '" & country & "'>"
Response.Write country & "</option>"
myRS.MoveNext
Wend
Response.Write "</select>"
myRS.Close
%>
</td>
</tr>
<tr>
<td width="148" height="49"> </td>
<td width="257" cellspace="0" valign="top" align="left" height="49"><b>Primary
telephone number<br>
<input name="telephone1">
</b></td>
<td cellspace="0" valign="top" align="left" height="49" width="9">
<p align="left"> </p>
</td>
<td cellspace="0" valign="top" align="left" height="49" colspan="3" width="276"><b>Alternate
telephone number<br>
<input name="telephone2">
</b></td>
</tr>
<tr>
<td width="148"> </td>
<td width="257" align="left" valign="top"><b>Primary email <font color="#FF0000">*</font><br>
<input name="email1">
</b>
<td width="9" align="left" valign="top">
<td colspan="3" align="left" valign="top" width="276"><b>Alternate email<br>
<input name="email2">
</b>
<tr>
<td width="148"> </td>
<td colspan="5" align="left" valign="top" width="550"><b><br>
Website</b><br>
<input name="website" size="35">
<tr>
<td width="148"> </td>
<td width="257" align="left" valign="top"><b>
Type of Business:<font color="#FF0000">*</font></b><br>
<%
Dim btype
Response.Write "<select name = 'type'>"
Response.Write "<option value=''>Choose a Business Category</option>"
Set myRS = Server.CreateObject("ADODB.Recordset"
myRS.Open "SELECT * FROM worktype order by type", myConn
While Not myRS.EOF
btype = myRS("type"
Response.Write "<option value = '" & btype & "'>"
Response.Write btype & "</option>"
myRS.MoveNext
Wend
Response.Write "</select>"
myRS.Close
Set myRS= Nothing
myconn.Close
Set myConn= Nothing
%>
</td>
<td width="9" align="left" valign="top"> </td>
<td colspan="4" align="left" valign="top" width="287"><b>
Describe your type of business:<br>
<textarea name="description" cols="20" rows="1"></textarea>
</b>
</tr>
<tr>
<td width="148"> </td>
<td width="257" align="right" valign="top"> <br>
<input type="submit" value="Add entry" name="Submit">
<td width="9" align="right" valign="top">
<td colspan="4" align="left" valign="top" width="287"> <br>
<input type="reset" value="Clear">
</tr>
<script language=VBScript>
Sub btnSubmit_OnClick()
If Len (frmaddpersonform.txtlname.value) = 0 then
Alert "You must enter your last name"
addpersonform.lname.focus
Exit sub
ElseIf Len (frmaddpersonform.txtfname.value) = 0 then
Alert "You must enter your first name"
addpersonform.fname.focus
Exit Sub
End if
Call frmaddpersonform.submit()
end sub
</script>
<tr>
<td width="148"> </td>
<td colspan="6" align="left" valign="top" width="561">
<hr noshade size="0" align="center">
<font size="1"><a href="index.html">Home</a>|<a href="searchpersonform.asp">People Search</a>| Organization/Business Search |<b>Add
personal record</b>| Add business/organization record</font> <br>
<hr size="0" noshade align="center">
<a href="mailto:itzel@mail.utexas.edu"><font size="2">itzel@mail.utexas.edu</font></a><font size="2"><br>
<font size="1">University of Texas<br>
Graduate School of Library and Information Science</font></font></td>
</tr>
</table>
</cfform>
</body>
</html>
</script>