HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
ASP Field Validation
Post new topic   Reply to topic    HTML Help Forum Index -> ASP
View previous topic :: View next topic  
Author Message
martinscott



Joined: 13 Jul 2009
Posts: 3

PostPosted: Mon Jul 13, 2009 5:19 am     ASP Field Validation Reply with quote

Hey Guys,
Any and all help would be greatly appreciated.

Here is a simple ASP script that collects information and sends an e-mail. There is only one problem. People can just submit a blank one. I have searched around the internet and cannot find any helpful tutorials on this. What I am needing to do is juat make it so that something must be entered in each field. Not anything complex at all, just so that it cannot be blank. One again, any and help would be appreciated. Here is the code:

<%
Dim UsableDate
UsableDate = WeekDayName(WeekDay(Date), true) & ", " & Day(Date) & " " & MonthName(Month(Date), true) & " " & Year(Date) & " " & FormatDateTime(DateAdd("h", 2, now), 4) & " (CST)"

Name = Request.Form("name")
UserEmail = Request.Form("email")
Company = Request.Form("Company")
Street = Request.Form("Street")
Street2 = Request.Form("Street2")
City = Request.Form("City")
State = Request.Form("State")
Zip = Request.Form("Zip")
Phone = Request.Form("phone")
Fax = Request.Form("fax")
Comments = Request.Form("comments")

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Mailer.RemoteHost = "mail.fakewebsite.com"
Mailer.AddRecipient "Sales", "mthomasatfakewebsite.com"
Mailer.FromName = "Online Brochure Request"
Mailer.FromAddress = "do_not_replyatfakewebsite.com"
Mailer.Subject = "Brochure Request"
Mailer.DateTime = UsableDate
If IsEmpty(UserEmail) or IsNull(UserEmail) or UserEmail="" then
Else
Mailer.ReplyTo = UserEmail
End If
Mailer.BodyText = "Date: " & UsableDate &_
VbCrLf &_
VbCrLf & "Name: " & Name &_
VbCrLf & "Company: " & Company &_
VbCrLf & "Email: " & Useremail &_
VbCrLf & "Phone: " & Phone &_
VbCrLf & "Fax: " & Fax &_
VbCrLf & "Street: " & Street &_
VbCrLf & "Street: " & Street2 &_
VbCrLf & "City: " & City &_
VbCrLf & "State: " & State &_
VbCrLf & "Zip: " & Zip &_
VbCrLf & "Comments: " & Comments &_
VbCrLf

'sends mail...required
if Mailer.SendMail then
Response.Redirect "http://www.fakewebsite.com/confirmation.html"
else
Response.Write "Mail send failure. Error was " & Mailer.Response
end if
%>

Thanks,



online seo training
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> ASP All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial