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.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Location
    Rialto, CA
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile Need Help with Tell a Friend Script

    I'm new to java script and placed a 'Tell a Friend' script from this site on my website. What I'm wondering, with this script, when the user clicks the submit button, they would have no idea that the info was sent. Also if the text boxes were empty, there was no check to ensure the proper information was entered.

    I found two other scripts that I thought would solve the problem. the first would popup a window with a thank you message. When I placed that script on my site, it did not work. I checked everything out and it seemed to be correct.

    The second was a script to ensure the textboxes were not blank by placing the script in the head and placing 'required' before the required name attributes (Name=requiredemail) in the form. It also did not work.

    Is there a script that would meet these conditions:
    Check to ensure correct data was entered, and displayed a message informing the sender that the data was sent? If there is a script, I believe I could learn by example. Just point me in the right direction, please.

    In my web development, I use four browsers to check my sites, Firefox, Opera, IE8, and Google Chrome. I checked the site with the scripts on all four browsers with the same results. I am new to javascript but not new to programing.

    Website Name: http://www.itsayorkieworld.com
    Page where Tell a Frind resides: Index.shtml

    Thanks,
    Bob...

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    I am afraid that we are not clairvoyant, so unless you post your (relevant) code it is hard to offer any advice. There are many such scripts out there, e.g.

    http://www.javascriptkit.com/script/...lafriend.shtml

    If you try this script you will see that modern browsers simply open the email program (if any) and ignore the form. So the message cannot be sent without the knowledge of the user - a security feature. Obviously Javascript must be enabled, and the user must have a suitable email client (some people have only Yahoo or Hotmail).

    If you are going to use a form with text fields then use a server-side formmail script as the action - there are several good free ones out there.

    As far as form validation is concerned, this topic has been covered a zillion times in this forum, and elsewhere.


    “There are two kinds of failures: those who thought and never did, and those who did and never thought.” - Dr. Laurence J. Peter quotes (American "hierarchiologist", Educator and Writer, 1919-1990)

  • Users who have thanked Philip M for this post:

    boblan66 (07-28-2009)

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,918
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    To follow on, here is an example of a mailto: form script. Test it and note the warnings raised.

    Code:
    <html>
    <head>
    <title>Form Example</title>
    </head>
    <body>
    <h1>Form Example</h1>
    
    Enter the following information. When you press the Submit button,
    the data you entered will be sent by email.
    
    <form name="form1" action="mailto:yourusername@whereever.com" 
     enctype="text/plain" method="post" onsubmit = "return validate()">
    
    <p><b>Name:</b> <input type="text" size="20" name="yourname">
    </p>
    <p><b>Address:</b> <input type="text" size="30" name="address">
    
    
    <p><input type="submit" value="Submit"></p>
    </form>
    
    <script type = "text/javascript">
    
    function validate() {
    var a = document.form1.yourname.value;
    if (a.length <2) {
    alert ("You must fill in your name");
    return false;
    }
    var b = document.form1.address.value;
    if (b.length <2) {
    alert ("You must fill in your email address");
    return false;
    }
    return true;
    }
    
    </script>
    </body>
    </html>

    BTW, "The second was a script to ensure the textboxes were not blank by placing the script in the head and placing 'required' before the required name attributes (Name=requiredemail) in the form. It also did not work." is a bit like saying "I signalled a right turn with my indicator, but nothing happened and the car (auto) just kept going straight on".
    Last edited by Philip M; 07-16-2009 at 09:49 AM.

  • #4
    New to the CF scene
    Join Date
    Jul 2009
    Location
    Rialto, CA
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for the code . I tried it and found the validation easy to follow. I can do something with that. I really don't think you have mystical powers, however what I was looking for was a good Opt-In script. I'm learning.....

    Thanks for the assist.


  •  

    Posting Permissions

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