Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: validation

  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    validation

    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

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    What would be the content of this form?

  • #3
    New Coder
    Join Date
    Aug 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    The following is an example I have on my site at:

    http://www.huntingground.freeserve.c...s/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>

  • #5
    New Coder
    Join Date
    Aug 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    What sort of file and in connection with what?

  • #7
    New Coder
    Join Date
    Aug 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #8
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    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

  • #9
    New Coder
    Join Date
    Aug 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #10
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    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>

  • #11
    New Coder
    Join Date
    Aug 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #12
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Do you mean that when you press the submit button, and the form is correctly filled in, a file automatically downloads?

  • #13
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Or go to a page where the download links are?

  • #14
    New Coder
    Join Date
    Aug 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Mr J
    Or go to a page where the download links are?

    you got it!

    :-)

  • #15
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    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.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •