...

View Full Version : validation



emma85
08-23-2002, 07:20 PM
hi

I'am lookin for a javascript that creates a form that needs to be filled in before the user can download a specific file from my site.

any of you know where I can find such script?


happycrappy
/Emma

Mr J
08-23-2002, 08:54 PM
What would be the content of this form?

emma85
08-24-2002, 11:13 AM
Originally posted by Mr J
What would be the content of this form?

just information about/from the user: name, address, ph, e-mail, and such...

/e

Mr J
08-24-2002, 08:09 PM
The following is an example I have on my site at:

www.huntingground.freeserve.co.uk/scripts/validate.htm

It really depends on the layout of your form as to how the script will be written.
If you need any more help let me know, I will where I can....help

<SCRIPT>
<!--
function check(){
var correct = true

if (document.Validate.name.value == ""){
correct = false; alert("Please Enter Your Name?")
}

if (document.Validate.email.value == ""){
correct = false; alert("Please Enter Your E-Mail Address?")
}

if(document.Validate.email.value.indexOf("@")==(-1)||document.Validate.email.value.indexOf(".")==(-1)){
correct=false; alert("Invalid email address")
}

if (document.Validate.comment.value == ""){
correct = false; alert("And Your Message Is?")
}
// Three button example
if(document.Validate.subject[0].checked==false&&document.Validate.subject[1].checked==false&&document.Validate.subject[2].checked==false){
correct=false;alert("Please select a language.")
}
// Two button example
if(document.Validate.number[0].checked==false&&document.Validate.number[1].checked==false){
correct=false;alert("Please select a number.")
}

if (correct){
alert("Thank you I will reply as soon as possible.")
}
return correct
}
//-->
</SCRIPT>

Add onsubmit="return check()" to the opening form tag

Below is the form that I have used for the above example.

<form name=Validate onsubmit="return check()">
<P>Name <input type=text name=name>
<P>E-Mail <input type=text name=email>
<P>Comment<Textarea name=comment></textarea>
English<INPUT type="radio" name="subject" value="English">
French<INPUT type="radio" name="subject" value="French">
Other<INPUT type="radio" name="subject" value="German">
One<INPUT type="radio" name="number" value="One">
Two<INPUT type="radio" name="number" value="Two">
<input type=submit value=Submit>
</form>

emma85
08-25-2002, 12:06 PM
hey,
okay, thanks! that form is okay.
but.
my next prob is that I want the user to be able to download a file from my site, after filling the form. if the person didn't fill the form, he can't download.
but maybe that requires some sort of cgi-stuff?
what you think?
/emma

Mr J
08-25-2002, 01:31 PM
What sort of file and in connection with what?

emma85
08-25-2002, 05:36 PM
Originally posted by Mr J
What sort of file and in connection with what?

In this case it's a pdf-file, but what did you mean by 'in connection with what'?
/e

Mr J
08-25-2002, 07:01 PM
I meant was the file to be downloaded like a print off of the filled in form or, a seperate file altogether.


To download files from a website you can place the files in .zip
then put a link to that zip

emma85
08-27-2002, 01:46 PM
Originally posted by Mr J
I meant was the file to be downloaded like a print off of the filled in form or, a seperate file altogether.


To download files from a website you can place the files in .zip
then put a link to that zip


its a separate file.
I basically know how to put a file on my page. but take a look on this page:
http://www.beeweeb.com/download/dlmapper2k.shtml

that's what I wanna do: first fill in a form. then download - if the form was correctly filled, that is!

happycrappy
/emma

Mr J
08-27-2002, 08:04 PM
To download a file, first place it in a zip file then, you want a link to that zip file:


<A HREF="yourzipname.zip">Download this file</A>

emma85
08-28-2002, 03:22 PM
Originally posted by Mr J
To download a file, first place it in a zip file then, you want a link to that zip file:


<A HREF="yourzipname.zip">Download this file</A>


okay! thanx for your help.
but. hmm. I guess I can't explain what I mean. cause that part I quoted above, I understand! That is not the problem.
but hey, we can't have it all. but I'll search! /e

Mr J
08-28-2002, 04:05 PM
Do you mean that when you press the submit button, and the form is correctly filled in, a file automatically downloads?

Mr J
08-28-2002, 04:06 PM
Or go to a page where the download links are?

emma85
08-28-2002, 06:32 PM
Originally posted by Mr J
Or go to a page where the download links are?


you got it!

:-)

Mr J
08-29-2002, 03:38 PM
See if this works

Change the opening FORM tag for the following

<form name=Validate method="GET" ACTION="http://www.yoursite.co.uk/yourpage.htm" onsubmit="return check()">


The above includes the METHOD and ACTION attributes.

Change the ACTION path to that of your page.

I think it has to be an absolute path as well.

emma85
09-03-2002, 06:56 PM
Originally posted by Mr J
See if this works

Change the opening FORM tag for the following

<form name=Validate method="GET" ACTION="http://www.yoursite.co.uk/yourpage.htm" onsubmit="return check()">


The above includes the METHOD and ACTION attributes.

Change the ACTION path to that of your page.

I think it has to be an absolute path as well.


good man!

here is an other one, cause its one thing that I can't figure out.
how is the information from the form stored? Say. I want it in a file or an e-mail, sent to me.
how to do that?

/emma

saldikey
09-03-2002, 07:02 PM
here is really easy page for u http://www.scriptarchive.com/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum