View Full Version : Need Help with Tell a Friend Script

07-16-2009, 08:57 AM
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


Philip M
07-16-2009, 09:25 AM
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.


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)

Philip M
07-16-2009, 10:23 AM
To follow on, here is an example of a mailto: form script. Test it and note the warnings raised.

<title>Form Example</title>
<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><b>Address:</b> <input type="text" size="30" name="address">

<p><input type="submit" value="Submit"></p>

<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;


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". :D

07-28-2009, 08:54 PM
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.