Posts Tagged form

Save the Javascript!

I had a bit of a scare this morning when my web site editor (MUST get Dreamweaver back!) decided to delete a chunk of js from one of my client’s sites during a routine update. Hooray, I got to rewrite it. I figure that I ought to save it for posterity and my posterior somehow in case it happens again. It’s a working form validation script.

<script language=”JavaScript” type=”text/javascript”>
<!–
function checkform ( )
{if (form1.email.value == “”) {
alert( “Please enter your email address.” );
form1.email.focus();
return false ;
}
if (form1.FirstName.value == “”) {
alert( “Please enter your first name.” );
form1.FirstName.focus();
return false ;
}
if (form1.LastName.value == “”) {
alert( “Please enter your last name.” );
form1.LastName.focus();
return false ;
}
if (form1.company.value == “”) {
alert( “Please enter your company name.” );
form1.company.focus();
return false ;
}
if (form1.honeypot.value != “”) {
alert( “Do not enter anything into the last field. It catches bots.” );
form1.honeypot.focus();
return false ;
}
return true ;
}
//–>
</script>

This chunk of script is placed inside the <head> tags. My form looks like this:

<form action=”/gdform.asp” method=”post” name=”form1″ onsubmit=”return checkform();”><input name=”subject” value=”About ” type=”hidden” /><input name=”redirect” value=”/articles/thankyou.shtml” type=”hidden” />First
Name:<br />
<input name=”FirstName” type=”text” /><br />
Last Name:<br />
<input name=”LastName” type=”text” /><br />
Email:<br />
<input name=”email” type=”text” /><br />
Company or Organization:<br />
<input name=”company” type=”text” /><br />
Comments: <br />
<br />
<textarea name=”comments” cols=”40″ rows=”3″>Type
comments here.</textarea><br />
<br />
Put nothing in this field. It’s a bot catcher. <input size=”1″ name=”honeypot” /><br />
<input name=”submit” value=”submit” type=”submit” /><br />
</form>

I use a honeypot as a bot-catcher. It’s still in the early stages, so we’re seeing how it works, but I have not been thrilled with CAPTCHAs in the past. They seem to be going out of style, as well as being unreliable. Remember when using a form validation to modify the “onsubmit” of your form tags so that it runs the script. Also, in the form validation script, make sure that in the if (form1.LastName.value == “”) tag, “form1” corresponds to the name of your form, as specified in the “form” tag.

Advertisements

Comments (1)

GoDaddy Form Mail Woes

I have been working on a site for a few years now, and the bane of my existence has been email forms. Hosted by GoDaddy, this site required use of two or three forms, and I could never get any of them to work. There were no obvious .cgi emailers to use, and the .php emailers didn’t seem to work at all. When I tried hooking it up to the webformmailer.asp, I got an error message. I tried about sixty different things before I called GoDaddy out of pure frustration. Why wasn’t anything working?

Turns out, the account I was working with resides on one of their older servers. It doesn’t support PHP at all, so even though the .php emailers were there in my root folder, I couldn’t use them. I had to use an older .asp form, “gdform.asp”, which is noted on the site as being no longer supported. However, with the age of the server, it is the only thing supported for my specific situation. It was frustrating to find that out, but I’m glad that my form mail woes are finally over.

So, if you have GoDaddy and your form mail doesn’t seem to work, try putting “/gdform.asp” in your form action, set method to “post”.  And whatever you do, don’t delete gdform.asp out of your root folder, because even GoDaddy won’t be able to put it back. Also, make sure you’ve put an email in your hosting account so that the .asp form knows where to send it. Here’s a link to the page that tells you  how to do this.

Here’s a link to the GoDaddy Windows Hosting Form Mail section. I never did find it until my service representative sent me an email with the link.

Comments (3)