Form Validation Help Needed Please

Discussion in 'JavaScript' started by chimp, Dec 4, 2006.

  1. #1
    I am knew here so hi to everyone, I have been told by a friend that this site is particularly helpful so here goes.

    I have a form that i want to ensure is filled out correctly before the user is able to proceed. I am also advised that Javascript is the easiest way to do this, however i have no idea how to implememnt it.

    http://chimp.cc/start.htm

    If the user fails to fill out the terms and conditions box with a "Yes"when the user clicks submit, i want a message to pop up to tell them to complete it.

    and to return the user to that field for completion.

    I honestly have no idea how to do this, can someone please help me.

    I have attached the source code too.

    Cheers

    Andy
     

    Attached Files:

    chimp, Dec 4, 2006 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    krakjoe.info/elp/ChimpCode.zip

    you need to edit the form action to put it back how it was, and also, do you not want the file to submit the form to sendmail ?
     
    krakjoe, Dec 5, 2006 IP
  3. chimp

    chimp Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ok cheers, i just downloaded the file and opened it in firefox, tried to click the sumbmit button and the message appeared excactly as i wanted.

    However when it refreshes the screen it blanks out all the entered data.

    Also

    Yes what it is meant to do is populate an email with the fields from the form,

    I have no idea what to change within the form to get it too do what i want or what you suggested tho, so any further hep would be great thanks
     
    chimp, Dec 5, 2006 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    how about I validate the form stuff with php ? and send the mail with php ?

    that would be easier for me, and better for you I think ....
     
    krakjoe, Dec 5, 2006 IP
  5. chimp

    chimp Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    seriously i need all the hlp i can get with this so if thats the easiest option then i am more than happy to go with the flow..

    Many thanks
     
    chimp, Dec 5, 2006 IP
  6. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #6
    krakjoe.info/elp/ChimpHelp.phps

    Save it as whatever.php where whatever is your filename, I believe that does everything you need it to do :)

    @ krakjoe.info/elp/ChimpHelp.php
     
    krakjoe, Dec 5, 2006 IP
  7. chimp

    chimp Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ok thanks again,

    i have the file, i have renamed it start.php uploaded it to my webspace again,

    chimp.cc/start.php

    all seems ok, lists all the fields that are not populated yet even when i enter "yes" in the box it tells me i must agree to the terms.

    I should get the message if it is null or "Yes" is not entered

    Any ideas please?
     
    chimp, Dec 5, 2006 IP
  8. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #8
    krakjoe.info/elp/ChimpHelp.phps

    Downlaod again, sry, fixed....
     
    krakjoe, Dec 5, 2006 IP
  9. chimp

    chimp Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    ok i have done that you wanna try it

    cos even if i submit the form with all fields populated i still get a message to agree to the terms

    chimp.cc/start.php

    code now starts like:

    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    p {text-align: justify; padding: 10px;}
    </style>
    <?
    $sysmail = "myemail@addy";

    if ($_POST)
    {
     
    chimp, Dec 5, 2006 IP
  10. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #10
    download the above version and replace the old file, it definately works this time....
    krakjoe.info/elp/ChimpHelp.phps
     
    krakjoe, Dec 5, 2006 IP
  11. chimp

    chimp Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    ok i agree that works perfectly thanks,

    one last question...

    When the user has been promted with the "request submitted etc" and there is a "ok" button which bit do i change to redirect to a different page than the start.php page lets say "chimp.cc/"

    cheers
     
    chimp, Dec 5, 2006 IP
  12. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #12
    krakjoe.info/elp/ChimpHelp.phps

    done, download again ....
     
    krakjoe, Dec 5, 2006 IP
  13. chimp

    chimp Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    you are a STAR many many thanks for your help, i really do appreciate it.

    Andy
     
    chimp, Dec 5, 2006 IP
  14. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #14
    always a pleasure :)
     
    krakjoe, Dec 5, 2006 IP