Form Validation

C

cawilcox

Looking for way to prevent users from submitting FrontPage form without
filling in any information. Have set the form field validation on several
fields in form yet form can be submitted without any information being filled
in. Email that is sent once form is submitted only contains default values
for several fields on form.
 
K

Kevin Spencer

FrontPage form validation is done using JavaScript. If JavaScript is
disabled on the client machine, the form may be submitted without
validating. The alternative is to program your own form handler with
server-side validation, using ASP, PHP, or whatever server-side programming
technology is available on your hosting service.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 
R

Ronx

Ensure JavaScript (not VBscript - this is IE only) validation is
applied to the last field in the form, and that this field does not
have a default value, or has an invalid default value.
As Kevin said, if JavaScript is disabled on the browser, no client
side validation will work.
 
J

JDD Software

Dear Cawilcox,

You should:
1.) Rename your page so that it has the .asp extention. (example: contact.asp)
2.) Make sure that your form and form fields have id's. (example:<input
type="text" id="first_name" value="">
3.) Set the target attribute for the form as follows:(<form
action="<%=Request.ServerVariables("PATH_INFO")%>" method="post">
4.) At the very top of the page write the following code:

<%
'Declare variables
Dim sMsg
Dim sTo
Dim sFrom
Dim sSubject
Dim sTextBody

'Get data from page
sFirst_Name = Request("First_Name")

'Make sure the first name field is not blank
If Request("First_Name") <> "" Then

Dim objMail
'Create the mail object
Set objMail = Server.CreateObject("CDO.Message")
'Set key properties
objMail.From = "Your website name"
objMail.To = "(e-mail address removed)"
objMail.Subject= "Contact info"
objMail.TextBody = sFirst_Name

'Send the email
objMail.Send
'Set sMsg which will be used later
sMsg = "Your message was sent to"

'Clean-up
Set objMail = Nothing

Else
sMsg = "Please enter your first name"

End If
%>

If you need help you can contact me directly and I'll be happy to assist.
Regards,
Robert
(e-mail address removed)
 
K

Kevin Spencer

2.) Make sure that your form and form fields have id's. (example:<input
type="text" id="first_name" value="">

id attributes are not transmitted with the Request. If you want to give code
to someone who (1) may not be running her web site on a Windows server, (2)
doesn't necessarily know anything about HTML, and (3) doesn't necessarily
know anything about ASP, it would be a good idea to make sure that you debug
your code first, include HTML, and explain what you are providing.

Cathy, I hope you don't waste your time with this. It is likely to give you
grey hair before your time. It is a very incomplete, and partially incorrect
server-side ASP form handler. If you want to write your own form handler,
learn whatever server-side programming technology that you want to (and that
is supported by your hosting service), and either write it yourself, or find
some reliable tutorial and/or source code that you can use or modify to suit
your purpose.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven
 
J

JDD Software

Kevin,

First of all I didn't realize this was a forum for bashing developers trying
to help out. Secondly, it's hard to find a web host who doesn't offer ASP.
Lastly, if the users aren't using Microsoft technology then why are they in
this news group?

I was under the impression that users were looking for SOLUTIONS to their
problems here and not dead-end responses like "If JavaScript is disabled…"
then you're pretty much screwed. I have always welcomed constructive
criticism and now that I know that this is an absolute newbie news group I'll
take your advice and post solid code from now on. Hopefully you’ll take mine
and stop leaving users hanging in the wind.

Microsoft is trying to make coding fun again. Don't you think that showing
users that they can overcome the boundaries of an application will help aid
in this objective?

Regards
Robert McGee
JDD Software
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top