Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form validation 1

Status
Not open for further replies.

exphtur

Technical User
Jul 23, 2003
23
IE
I am having a problem with validation, I have a new members registration form which works at calling up the second form and adding the details to my Microsoft Access database, the problem I have is that I want to validate it using VB Script for missing name address number etc but I can't seem to get this to work. The code from the two forms are below. Any help would be very much appreciated. Thank you


This is the new member registration form:
<form name="form" method="post" action="addnewmember2.asp">
<table width="80%" border="0">
<tr>
<td width="63%"><div align="right"><font face="Arial, Helvetica, sans-serif">First Name:</font></div></td>
<td width="37%"><input name="txtName" type="text" size="15" maxlength="30"></td>
</tr>
<tr>
<td height="28"><div align="right"><font face="Arial, Helvetica, sans-serif">Last Name:</font></div></td>
<td><input name="txtName2" type="text" size="15" maxlength="20"></td>
</tr>
<tr>
<td><div align="right"><font face="Arial, Helvetica, sans-serif">Address1:</font></div></td>
<td><input name="txtAddress1" type="text" size="24"></td>
</tr>
<tr>
<td><div align="right"><font face="Arial, Helvetica, sans-serif">Address2:</font></div></td>
<td><input type="text" name="txtAddress2"></td>
</tr>
<tr>
<td height="27"><div align="right"><font face="Arial, Helvetica, sans-serif">Date of
Birth:</font></div></td>
<td><input name="txtDOB" type="number" size="10" maxlength="12"></td>
</tr>
<tr>
<td><div align="right"><font face="Arial, Helvetica, sans-serif">Telephone
No:</font></div></td>
<td><input name="txtTelephone" type="number" size="15"></td>
</tr>
<tr>
<td><div align="right"><font face="Arial, Helvetica, sans-serif">Mobile No:</font></div></td>
<td><input name="txtMobile" type="number" size="15"></td>
</tr>
<tr>
<td><div align="right"><font face="Arial, Helvetica, sans-serif">Email :</font></div></td>
<td><input type="text" name="txtEmail"></td>
</tr>
<tr>
<td><div align="right"><font face="Arial, Helvetica, sans-serif">UserName:</font></div></td>
<td><input name="txtUserName" type="text" size="15"></td>
</tr>
<tr>
<td><div align="right"><font face="Arial, Helvetica, sans-serif">Password:</font></div></td>
<td><input name="txtPassword" type="text" size="15"></td>
</tr>
<tr>
<td><div align="right"> <input type="submit" name="Submit" value="Submit"><input type="reset" name="reset" value="Reset"></div></td>
</tr>

</table>
</form>

This is the second form

<%

dim conn, rs, sql, intTelephone, intMobile
set rs = Server.CreateObject ("ADODB.Recordset")


Set conn = Server.CreateObject("ADODB.Connection")

conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Z:\videostore\videostore.mdb;Persist Security Info=False"
sql = "SELECT * FROM [tblMember]"
rs.open sql, conn, 3, 3

strFName= Trim(Request.Form("txtName"))
strLName=Trim(Request.Form("txtName2"))
strAddress1=Trim(Request.Form("txtAddress1"))
strAddress2=Trim(Request.Form("txtAddress2"))
strDOB=Trim(Request.Form("txtDOB"))
intTelephone=Trim(Request.Form("txtTelephone"))
intMobile=Trim(Request.Form("txtMobile"))
strEmail=Trim(Request.Form("txtEmail"))
strUserName=Trim(Request.Form("txtUserName"))
strPassword=Trim(Request.Form("txtPassword"))

rs.AddNew
rs("FName")=strFName
rs("LName")=strLName
rs("Address1")=strAddress1
rs("Address2")=strAddress2
rs("DOB")=strDOB
rs("Phone")=intTelephone
rs("Mobile")=intMobile
rs("Email")=strEmail
rs("UserName")=strUserName
rs("Password")=strPassword

rs.Update
rs.close
Response.Redirect "login.asp"

%>
 
Do a keyword search in this forum for form validation.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
exphtur,

You have no code that is validating the values. If you didn't post it, please do so in order for us to help you.

If you don't have any, create a function that validates all your required values, passing back any error messages. Like this:

strErrorMessage = ValidateNewMember(strFName, strLName, strAddress1)

If strErrorMessage = "" Then
'No error. Insert record.
Else
'We had an error. Do nothing, err msg will be displayed.
End If

response.write (strErrorMessage)

Within the function ValidateNewMember, use the Len() function to deteremine if the value were supplied.

Post back if you need more help.

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top