On 28 Jan 2009 in macromedia.exchange.extensions.dreamweaver,
mauth
wrote:
> Although I've had forms on my site for several years,
have recently
> been receiving too many forms filled out by robots
(according to my
> domain host). They suggested a way of defeating them by
including a
> hidden field; then, when the bot fills in the hidden
field, it would
> signal that the form should NOT be sent.
>
> Does anyone know how to do this reverse logic? I can
insert a
> hidden field,
> but cannot find how to direct behavior if it is filled
in.
>
> Any thoughts appreciated.
Actually, best practice seems to be to use two hidden fields,
one with
an initial value, and one without. It's the rare bot which
can ignore
both fields. Check for one field to be blank, and the other
to have
the initial value. And hide them using CSS, not by making
them
"hidden" fields:
<style type="text/css">
.important {
display : none ;
}
</style>
<div class="important">
<p>Please don't change the next two fields.</p>
<input type="text" name="address2" id="address2"
value="xyzzy">
<input type="text" name="address3" id="address3"
value="">
</div>
Bots tend to like fields with names like 'address'. The text
in the
paragraph is for those few rare human beings who have a
non-CSS capable
browser. If you're not worried about them, you can leave it
out.
In the logic for processing the form, you'd do something
like:
if (address2 == "xyzzy" and address3 == "") {
/* OK to send */
} else {
/* probably have a bot */
}
--
Joe Makowiec
http://makowiec.net/
Email:
http://makowiec.net/contact.php