Recently there was a discussion in nanae (the news.admin.net-abuse.email newsgroup) about what method would be best for collecting email addresses from web site visitors. One side of the argument insisted the form should default to "Do not send me email". The other side insisted the form should default to "Please send me email". (It was understood that the email address would be collected somewhere else in the form.)
This page offers (and demonstrates) a third alternative - neither radio button should be checked by default. The purpose of this page is to show how a radio button method of collecting email addresses could be set up so that the viewer must chose one button, and if they don't, an error will be returned.
In most browsers, neither radio button will be checked when the page is first visited. In some browsers, the first radio button (in this case "Please send me email.") will be checked. However, the Perl script will not allow the form to be sent until an email address is entered. The script will error out unless the viewer either consciously checks "Please send me email." and enters an email address or checks "Please do not send me email.". In addition, the script checks the domain name using nslookup to verify that it is an existing domain.
The following form is used to demonstrate this technique.
<FORM ACTION="/cgi-bin/cgiwrap/pauls/email.cgi"
METHOD="POST">
Please check one of the two buttons before submitting this form.<BR>
Please send me email.
<INPUT TYPE="Radio" VALUE="Yes"
NAME="email">
Enter your email address here. <INPUT
TYPE="Text" MAXLENGTH="50"
NAME="address"><BR>
Please do not send me email.
<INPUT TYPE="Radio" VALUE="No" NAME="email"><BR>
If you'd like to comment on this site, you may enter your comments here.<BR>
<TEXTAREA NAME="comments" COLS="75" ROWS="10" WRAP="VIRTUAL"></TEXTAREA><BR>
<INPUT TYPE="Reset"><BR>
<INPUT TYPE="Submit" VALUE="Submit">
</FORM>
This form should not have either button checked when first viewed. (As I mentioned earlier, some browsers will check the first radio button in a group by default.) If you press the RESET button, both buttons should be unchecked. If you try to send the form without checking one of the two buttons, the cgi script should indicate an error and tell you to hit the BACK button in your browser to correct the error.
If you check the first button ("Please send me email."), the script will return an error if you don't enter a correct email address with the format username@domain.name. The domain name must also be an existing domain that can be verified by nslookup. Please feel free to try any and all combinations to your satisfaction. (If something doesn't work right, please let me know.)
Note that I did not pay a lot of attention to the details of wording and such. This form is designed simply to demonstrate the technique used. You may feel free to copy both the form and the perl script for your own use. I would urge you to rework the wording so it's more professional. As with all things free for the taking, this technique, the form and the perl script come with no warranties, express or implied. Use them at your own risk, and test them thoroughly before placing them in a production environment.
Please note: every time you successfully fill out this form, I will get email. If you answer yes and provide your email address, I will get email with your email address, your Remote Host Name and your IP address. Even if you check the NO choice, I will get email with your Remote Host Name and IP address. Do not fill out this form if you do not want me to have your email address or your Remote Host Name and IP address.
This procedure is a work in progress. As I make and test changes to the script, those changes will show up here. USE AT YOUR OWN RISK!!! If you use a domain name of the format machinename.domain.name, unless your DNS is set up to resolve to the domain name nslookup will fail, so if the script returns a "Invalid Domain" error, try using just the domain name without the machine name. (E.g. username@mail.host.com may not work, but username@host.com should.)
Click here to see the Perl script used to error check this form.
Last revised: Tuesday, 04-Apr-2006 01:11:12 CDT