Click to See Complete Forum and Search --> : Help w/No Entry JS - only works on one browser...
lpmaya
01-28-2003, 10:55 AM
Hi All
I'm hoping someone could help. I have created a basic form. (I am currently running the FormMail Script on this form).
One of the feedbacks I got was "It would be easier and save more time if I had gotten the form back w/ the information I had already input and let me make the corrections vs. having to input the entire form again."
I found the No Entry JS on http://javascript.internet.com/forms/no-entry.html. I followed the instructions and the script works well with IE 5 but does not work w/Netscape.
I have looked through the sights hoping to find one that works for both browsers and that dosen't conflict with FormMail but I haven't been able to find one.
Can anyone help?
Thanks
Below is the no-entry form script as found on javascript.internet.com:
<!-- THREE STEPS TO INSTALL NO ENTRY:
1. Paste the coding into the HEAD of your HTML document
2. Put the last code into the BODY of your HTML document
3. Change the form's ACTION to point to your Form Mail CGI-Script -->
<!-- STEP ONE: Copy this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function noEntry() {
mt=document.form.entry.value;
if ((mt.length<1)||(mt.substring(0,6)=="******")) {
alert("I'm sorry. This entry must be "
+"completed before I can submit this form"
+" for processing.");
document.form.entry.value="******Please Complete This Entry";
document.form.entry.focus();
return false;
}
else { return true; }
}
// End -->
</SCRIPT>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<form name="form" action="/cgi-bin/your-form-processor.pl" onsubmit="return noEntry()">
<center>
<input type="text" name="entry" size=40><br>
<input type="submit" name="button" value="submit">
</center>
</form>
<!-- STEP THREE: Change the form's ACTION to point to your Form Mail CGI-Script -->
<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.00 KB -->
gil davis
01-28-2003, 12:39 PM
There is nothing wrong with the script you posted. It works fine in Netscape.
If you would like to post a link to your version, perhaps someone can show you where you went wrong.
lpmaya
01-28-2003, 01:21 PM
Hi
Thanks for your response. I'm unable to post a link (it's an internal site) but I can show you the script/form. Please see below:
<body text="#000000" bgcolor="#ffffff" link="#3366cc" vlink="#9966cc" alink="#ff0000" marginwidth = "0" marginheight = "0" topmargin="0" leftmargin="0">
<!-- Begin Form -->
<form name="form" action="FormMail.cgi" onsubmit="return noEntry()">
<input type=hidden name="recipient" value="lpmaya@crfcine.com">
<!-- Begin table for from -->
<TABLE BGCOLOR="#ffff99" BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH="533">
<tr>
<td> <div align="center">
<label>
<input type="radio" name="Order_Type" value="Employee Related">
<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Employee
Related</strong></font></label>
<label>
<input type="radio" name="Order_Type" value="Review Immediately">
<font size="1" face="Arial, Helvetica, sans-serif"><strong><font face="Verdana, Arial, Helvetica, sans-serif">Review
Immediately</font></strong></font></label>
<label>
<input type="radio" name="Order_Type" value="Previous Filed">
<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Previous
Filed</strong></font></label>
<label>
<input type="radio" name="Order_Type" value="Missing">
<font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Missing</strong></font></label>
</div></td>
</tr>
</table>
<TABLE BGCOLOR="#ffff99" BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH="533">
<tr>
<td width="216"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Name:<br></strong></font>
<input name="Name" type="text" id="Name"></div></td>
<td width="216"><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Order#:<br></strong></font>
<input name="Order_N" type="text" id="Order_N"></div></td>
</tr>
</table>
<TABLE BGCOLOR="#ffff99" BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH="533">
<tr>
<td><div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><strong>Address: </strong></font>
<input name="Address" type="text" size="30" id="Address"></div></td>
</tr>
</table>
<TABLE BGCOLOR="#ffff99" BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH="533">
<tr>
<tr>
<td><div align="center"><input type="submit" name="Submit" value="Submit" /><INPUT TYPE="RESET" VALUE="Clear Form"></div></td>
</tr>
</table>
<!-- Begin Required Section of form -->
<input type=hidden name="required" value="Order_Type,Name,Order_N">
<input type=hidden name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT">
<input type=hidden name="sort" value="alphabetic">
<input type=hidden name="print_config" value="Order_Type,Name,Order_N">
<input type=hidden name="print_blank_fields" value="1">
<input type=hidden name="title" value="Orderline Form">
<input type=hidden name="sort" value="order:Order_Type,Name,Order_N">
<!-- End Required Section of form -->
</form>
<!-- End of form -->
</body>
</html>
What do you think?...Thanks again :)
gil davis
01-28-2003, 01:38 PM
Originally posted by lpmaya
What do you think?I think you have missed the point. Where's the script? All you posted was HTML.
We need to see EXACTLY what you are working on. No one will be able to help you unless you can do that.
You have the option of attaching either a zip or txt file to this forum.
lpmaya
01-28-2003, 01:51 PM
Sorry that's what I get for cutting and pasting quickly and not proof reading my post.
Please see the attached file.
Thank you.
gil davis
01-28-2003, 02:17 PM
Your validation script is looking for a text field with the name "entry" in a form named "form". Your HTML has a form named "form", but has no fields named "entry".
Your form has three text fields: Name, order_N, and Address. If I understand what you want the validation to do, you need to change the script to check those three fields.
It's not that it's broken, it's more like you don't seem to know how to use it as an example, and adapt it to your particular form.
lpmaya
01-28-2003, 02:33 PM
Hi
Thanks for looking at the document.
I orginially set up the form to work with FormMail. I created a "required" section in the FormMail script. Currently if anyone attempts to submit the form with fields missing it will return an error message and indicates to the submitter what's missing. However when they hit the back button on the browser any information they've inputted is earsed and they have to fill out the form all over again.
While looking through JS I found this No-entry script hoping it would solve the problem, I made no adjustments to it becuase I have no experience with JS. I basically cut and pasted.
I didn't think the script was broken, I just figured since it worked with IE and not Netscape, I left something out.
Where on the No Entry Form script would I need to make the changes?
lpmaya
01-29-2003, 09:38 AM
Hi Everyone
If anyone can find the time to review the doc attached in the previous post and offer some help (as I'm a JS novice).
I would greatly appreciate it.
Thanks!
ScreenMan
01-29-2003, 06:37 PM
I Believe the proper coding you are looking for is in the attached file below. I made some adjustments to your original file and this is what I came up with. It should work!
You can compare this file with your original to see what I have changed.:)
lpmaya
01-30-2003, 10:32 AM
Hi ScreenMan :)
Thank you for your response. I looked over the changes you had made and I wanted to ask you.
If I were to make the form larger (add 10 more fields) I would have to copy and past for each field that I want validated correct?
Also in the form section I noticed you changed this :
<form name="form" action="FormMail.cgi" onsubmit="return noEntry()">
to this:
<form action="FormMail.cgi" method="POST" name="form" onsubmit="return noEntry()">
Since it's a FromMail script (information is submitted via email) how does the method="POST" work in this instant?
Also the form has a "required section" already setup:
<!-- Begin Required Section of form -->
<input type=hidden name="required" value="Order_Type,Name,Order_N">
<input type=hidden name="env_report" value="REMOTE_HOST,HTTP_USER_AGENT">
<input type=hidden name="sort" value="alphabetic">
<input type=hidden name="print_config" value="Order_Type,Name,Order_N">
<input type=hidden name="print_blank_fields" value="1">
<input type=hidden name="title" value="Orderline Form">
<input type=hidden name="sort" value="order:Order_Type,Name,Order_N">
<!-- End Required Section of form -->
Is JS working in conjuction w/this or is it overriding it? Do I even need it on the form?
Thanks
ScreenMan
01-31-2003, 11:06 AM
To your first question the short answer is yes. You must copy and paste for each field you want validated. There are other methods however. You could use a loop for instance. But that is more complicated and I didn't have time to figure out one for the above situation. I suggest you look up information on looping and see what you come up with.
To your second question, even though you're using formmail, formmail is still a cgi script not an email address. So you should provide the POST method to post the field info to your formmail.cgi script so it knows what information to email. If you leave it out it may work because the default setting might be POST and not GET, but I would include it to avoid problems.
Third, the required hidden fields that you included are nessesary. On most formmail.cgi scripts the only field you MUST provide to formmail is the recipient field. The rest are usually optional.
Such as the required field. The required field tells formmail that whatever is in its value="" variable, is required and must be filled out before formmail will execute properly. So if you put <input type=hidden name="required" value="Contact_Name">, then formail will check to see if the "Contact_Name" field is null or has a value. If it has a value then formail will continue as normal.
Else, it will give you a message screen that says that the required field has not been filled out. And to press your browsers back button and fill it in.
The problem with this however is that on some browsers, when you press your back button, your information that you DID fill in has disappeared.
To fix this we use javascript to not alow you to submit the form to formmail at all, unless the required fields are filled in. In this case javascript is working on its own, and does not tell anything to formail at all.
So you ask, if javascript wont allow anyone to submit the form without all the required fields filled in, then we don't really need formmail to validate the fields a second time do we?
No you don't. But I would Advise it! Because some people have javascript disabled in there browsers options. There's nothing you can do to override this. So it would be a good idea to have a backup system just in case.
The other hidden fields I noticed you have are things like environmental variables and sort and such. The Environmental variables are not nessesary for formmail to work properly. They're values will be emailed to you or whomever the "recipient" is.
The values are things like The browser type that your customer was using to fill out the form. The host name and the IP address. And more...
`Sort' tells formail how to send the field values to your email address. Such as alphabetical. Or you can specify an exact order.
I just looked at your file again and realized that you used sort twice. You can't do that. You must choose alphabetical or specify the order you want. In this instance, one value overwrites the other. So it should still work but it doesn't need the first sort.
Like I stated earlier, USUALLY the only hidden field that you MUST have is recipient. The rest are optional.
This post is getting rather windy so I better cut off now. I hope this helped clear some things up for you. If not, at least you practiced your reading skills.;)