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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validation

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 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"

%>
 
HOPE THIS HELPS..
MAKE THE RELEVANT CHANGES AND ADD THIS IN IN YOUR FIRST PAGE THAT DISPLAYS THE FORM... formname is the name of your form, ie, in your form above its called "form"

<script language="Javascript">
function checksubmit()
{
if (document.formname.fullname.value == "")
{
alert("Please enter your full name")
document.formname.fullname.focus()
return false
}

if (document.formname.address1.value == "")
{
alert("Please enter your address1")
document.formname.address1.focus()
return false
}

if (document.formname.address2.value == "")
{
alert("Please enter your address2")
document.formname.address2.focus()
return false
}

return true
}

</script>

<body onLoad="document.formname.fullname.focus()">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top