Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JMail 2

Status
Not open for further replies.

markstuart

Technical User
Dec 7, 2001
4
GB
Hi, I have a form page that currently checks for the entry of data in one of the fields (email), I would like to be able to check that other fields have entries in them, I have posted the code currently being used below, any assistance would be gratefully recieved!

If request("email")="" then
Response.Write &quot;<h1>You Forgot to Enter your Email Address.<br><br>Please press your BACK Key and ensure you enter all the information.</h1>&quot;
ELSE
JMail.Sender=Request(&quot;email&quot;)
JMail.SenderName=Request(&quot;name&quot;)
'Modify the line below with the email address this form should be sent to!
 
This would probably me more appropriate in the ASP forum, but I will go ahead and answer it here.

You can check your other fields exactly like your checking your email field, except you will probably want to check them all before you start assigning them in the JMail object:
Code:
Dim errorFlag, errorMessage
errorFlag = False
errorMessage = &quot;&quot;

If Request(&quot;email&quot;) = &quot;&quot; Then
   errorFlag = True
   errorMessage =  errorMessage & &quot;The required field <u>email</u> has not been filled out.<br>&quot;
End If

If Request(&quot;name&quot;) = &quot;&quot; Then
   errorFlag = True
   errorMessage = errorMessage & &quot;The required field <u>name</u> has not been filled out.<br>&quot;
End If

'etc, etc, etc for all your fields

'then we just check the value of our errorFlag to decide whether to display it or write the email:
If errorFlag = True Then
   Response.Write errorMessage
   Response.Write &quot;Please use the browsers back button to return to the form and fill out these fields.&quot;
Else
   JMail.Sender = Request(&quot;email&quot;)
   'etc etc
End If


Some things to consider: Doing these checks on the form page using javascript will allow you to tell the user whats missing before they submit the form, so they won't have to use the back button.
You should also do checks for things like the @ sign in the email to verify that it is more than just a string, but in fact a validly formatted email address.

Hope this helps,
-Tarwn Experts are only people who have realized how much they will never know about a language.
________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top