Solved

VBScript Form Field Validation Help

Posted on 2004-08-04
11
765 Views
Last Modified: 2008-03-04
Hi  ,

I need assitance with a form , have multiple fields that need to be filled in and then want to email using CDOSYS.

Any ideas?

Form below:

Cheers

Stephen!


*Departure Date:                  *Return Date:      

*Departure Time:                  *Return Time:      

*Departure Airport:      

*Destination Airport:      

*Return Airport:

*Name and Address of Customer/Course, etc.:


*Hotel Accommodation:      Yes:             No:


* Mandatory fields
0
Comment
Question by:sgriffin
  • 5
  • 3
  • 3
11 Comments
 
LVL 16

Accepted Solution

by:
golfDoctor earned 125 total points
Comment Utility
<% for each i in request.form
        if i = "" then
               Response.write "Error, all information is necessary!"
               response.end
        end if
     next
   
    'Form OK, send CDO mail
%>
0
 
LVL 16

Expert Comment

by:golfDoctor
Comment Utility
0
 
LVL 2

Author Comment

by:sgriffin
Comment Utility
Can you help me with a few fields using the example above?
0
 
LVL 31

Expert Comment

by:alorentz
Comment Utility
The code provide by golfDoctor loops through all fields, so will validate entire form.  Try it!
0
 
LVL 2

Author Comment

by:sgriffin
Comment Utility
where do I place this code above? can anyone provide an example ?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 16

Expert Comment

by:golfDoctor
Comment Utility
Whereever your form posts to, you would put that code.
0
 
LVL 2

Author Comment

by:sgriffin
Comment Utility
If I were to use this example :

HTML>
<BODY>
<FORM ACTION="validate.asp" METHOD="POST">
Your Name: <INPUT TYPE="Text" NAME="name"><BR>
Your Email: <INPUT TYPE="Text" NAME="email"><BR>
Your ASP skills are:
<SELECT NAME="skills" SIZE="1">
<OPTION VALUE="I suck">I suck</OPTION>
<OPTION VALUE="Pretty bad">Pretty bad</OPTION>
<OPTION VALUE="Bad">Bad</OPTION>
<OPTION VALUE="Good">Good</OPTION>
<OPTION VALUE="Excelent">Excelent</OPTION>
<OPTION VALUE="Better than yours!">Better than yours!</OPTION>
</SELECT>
<BR>
Comment:<BR>
<TEXTAREA NAME="comment" COLS="20" ROWS="5" WRAP="VIRTUAL"></TEXTAREA><BR>
<INPUT TYPE="Submit" VALUE="Submit">
</FORM>
</BODY>
</HTML>


And I am posting back to the same page , where would I place the check code? As you can see Ive little experience with ASP form validation....

Cheers!
0
 
LVL 31

Expert Comment

by:alorentz
Comment Utility
Validate.asp:

'golfDoctor code

<%
 for each i in request.form
        if i = "" then
               Response.write "Error, all information is necessary!"
               response.end
        end if
     next
   

Dim objCDOSYSCon

'Create e-mail server object
Set objCDOSYSMail= Server.CreateObject("CDO.Message")

'Who the e-mail is from
objCDOSYSMail.From = "yourname@yourdomain.com"  '<------------------hardcode your email to test

'Who the e-mail is sent to
objCDOSYSMail.To ="yourname@yourdomain.com"  '<------------------hardcode your email to test -- send to yourself!
'The subject of the e-mail
objCDOSYSMail.Subject ="This is the subject"
'Set the e-mail body format (HTMLBody=HTML TextBody=Plain)
objCDOSYSMail.HTMLBody="<b>Hello</b>"  '<---------------------this line was wrong regardless of the rest
Send the e-mail
objCDOSYSMail.Send

'Close the server mail object
Set objCDOSYSMail = Nothing



%>
0
 
LVL 2

Author Comment

by:sgriffin
Comment Utility
I tried the folllowing which doesnt work, where do I put the code ?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<HTML>
<BODY>
<FORM ACTION="ask.asp" METHOD="POST">
Your Name: <INPUT TYPE="Text" NAME="name"><BR>
Your Email: <INPUT TYPE="Text" NAME="email"><BR>
Your skills are:
<SELECT NAME="skills" SIZE="1">
<OPTION VALUE="A">A</OPTION>
<OPTION VALUE="B">B</OPTION>
</SELECT>
<BR>
Comment:<BR>
<TEXTAREA NAME="comment" COLS="20" ROWS="5" WRAP="VIRTUAL"></TEXTAREA><BR>
<INPUT TYPE="Submit" VALUE="Submit">
</FORM>
<% for each i in request.form
        if i = "" then
               Response.write "Error, all information is necessary!"
               response.end
        end if
     next
       %>
</BODY>
</HTML>
0
 
LVL 31

Expert Comment

by:alorentz
Comment Utility
Sorry man, its all there....you'll figure it out.  Don't have time now.
0
 
LVL 2

Author Comment

by:sgriffin
Comment Utility
Can anyone have a look at code posted and advise.

thanks

Stephen
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now