Solved

VBScript Form Field Validation Help

Posted on 2004-08-04
11
769 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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 information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

863 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

28 Experts available now in Live!

Get 1:1 Help Now