Solved

VBScript Form Field Validation Help

Posted on 2004-08-04
11
778 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
11 Comments
 
LVL 16

Accepted Solution

by:
golfDoctor earned 125 total points
ID: 11716743
<% 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
ID: 11716762
0
 
LVL 2

Author Comment

by:sgriffin
ID: 11716764
Can you help me with a few fields using the example above?
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 31

Expert Comment

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

Author Comment

by:sgriffin
ID: 11716802
where do I place this code above? can anyone provide an example ?
0
 
LVL 16

Expert Comment

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

Author Comment

by:sgriffin
ID: 11717020
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
ID: 11717070
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
ID: 11717275
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
ID: 11717696
Sorry man, its all there....you'll figure it out.  Don't have time now.
0
 
LVL 2

Author Comment

by:sgriffin
ID: 11717745
Can anyone have a look at code posted and advise.

thanks

Stephen
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Html Table looping 4 42
CREATE DATABASE 3 46
send email part1 9 53
SP converting date time to date and time separately 2 40
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…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

759 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