Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBScript Form Field Validation Help

Posted on 2004-08-04
11
Medium Priority
?
781 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 250 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 2

Author Comment

by:sgriffin
ID: 11716764
Can you help me with a few fields using the example above?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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/…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Loops Section Overview
Suggested Courses

772 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