Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Form valitaion before sending to database


Message #1 by "Andrew Mesplay" <amesplay@g...> on Sat, 11 Jan 2003 09:13:21
I have a simple form that displays the data entered with two arrays. I 
want to use an array to check the form for balnk entries and redirect the 
user back to the form if that is the case. Eventually I want to add the 
form data to an Access data base, but that is for another time. Here is 
the code that I've written so far:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">
'I know that I need to have a routine here,
'But I'm at a loss. Please help.
</SCRIPT>
<TITLE>Some Input Form</TITLE>
</HEAD>
<BODY>
<FORM ACTION="SomeFormConfirmation.asp" NAME=SomeForm METHOD=POST>
<B>First Name:</B><INPUT TYPE=TEXT NAME="SomeFormInfo(0)">
<B>Last Name:</B><INPUT TYPE=TEXT NAME="SomeFormInfo(1)">
<B>Occupation:</B><INPUT TYPE=TEXT NAME="SomeFormInfo(2)">
<INPUT TYPE=SUBMIT NAME=SUBMIT Value=SUBMIT OnClick="SomeSub_Check()">
<INPUT TYPE=RESET	NAME=RESET VALUE=RESET>
</FORM>
</BODY>
</HTML>
Message #2 by "Andrew Mesplay" <amesplay@g...> on Sat, 11 Jan 2003 09:19:43
This is the code for the SomeFormConfirmation.asp page reffered to in the 
above code. I didn't have enough room in one post. :)
<HTML>
<HEAD>
<title>Some Form Confirmation</title>
</HEAD>

<body>
<%
Dim strSomeFormInfo(),strSomeFormHeading(),i
Redim strSomeFormInfo(2),strSomeFormHeading(2)

strSomeFormInfo(0) = Request.Form("SomeFormInfo(0)")
strSomeFormInfo(1) = Request.Form("SomeFormInfo(1)")
strSomeFormInfo(2) = Request.Form("SomeFormInfo(2)")

strSomeFormHeading(0) = "<B><I>Name: </I></B>"
strSomeFormHeading(1) = "<B><I>Last Name: </I></B>"
strSomeFormHeading(2) = "<B><I>Occupation: </I></B>"

For i = 0 to 2
	Response.Write "<B>" & strSomeFormHeading(i) & strSomeFormInfo(i)
& "<BR>"
Next
%>
</BODY>
</HTML>
Message #3 by "Drew, Ron" <RDrew@B...> on Sat, 11 Jan 2003 17:17:53 -0500
Javascipt..
<script language=3D"JavaScript">
<!--
function CheckForm() {
if (document.SomeForm.SomeFormInfo(0).value =3D=3D "" &
document.SomeForm.SomeFormInfo(1).value =3D=3D "" &
document.SomeForm.SomeFormInfo(2).value =3D=3D "" )
   {
    alert("Please enter a value for the \"fields.");
    document.SomeForm.SomeFormInfo(0).focus();
    return (false);
   }
 return (true);
}
//-->
</script>
<FORM ACTION=3D"SomeFormConfirmation.asp" NAME=3DSomeForm METHOD=3DPOST
onsubmit=3D"return CheckForm()">

-----Original Message-----
From: Andrew Mesplay [mailto:amesplay@g...]
Sent: Saturday, January 11, 2003 4:13 AM
To: ASP Databases
Subject: [asp_databases] Form valitaion before sending to database


I have a simple form that displays the data entered with two arrays. I
want to use an array to check the form for balnk entries and redirect
the
user back to the form if that is the case. Eventually I want to add the
form data to an Access data base, but that is for another time. Here is
the code that I've written so far:

<HTML>
<HEAD>
<SCRIPT LANGUAGE=3D"VBScript">
'I know that I need to have a routine here,
'But I'm at a loss. Please help.
</SCRIPT>
<TITLE>Some Input Form</TITLE>
</HEAD>
<BODY>
<FORM ACTION=3D"SomeFormConfirmation.asp" NAME=3DSomeForm METHOD=3DPOST>
<B>First Name:</B><INPUT TYPE=3DTEXT NAME=3D"SomeFormInfo(0)"> <B>Last
Name:</B><INPUT TYPE=3DTEXT NAME=3D"SomeFormInfo(1)">
<B>Occupation:</B><INPUT TYPE=3DTEXT NAME=3D"SomeFormInfo(2)"> <INPUT
TYPE=3DSUBMIT NAME=3DSUBMIT Value=3DSUBMIT OnClick=3D"SomeSub_Check()">
<INPUT TYPE=3DRESET	NAME=3DRESET VALUE=3DRESET>
</FORM>
</BODY>
</HTML>

  Return to Index