If you don't want Honeypot module as mentioned by Jimajamma, you can do it with Form API #attributes
all right:
$form['pass'] = array(
'#type' => 'password',
'#title' => t('Password'),
'#maxlength' => 64,
'#size' => 15,
'#attributes' = array('style' => array('display:none;'));
);
Of course it's easy to catch display:none
in bot's code. It's also common and not so much harder to find out that class applied is styled with it in CSS. There are two methods that are not yet so easy to catch:
- Using box model and overflow to make element hidden under other HTML boxes.
- JavaScript code to move it out of sight or apply
display: none
to it
In both cases you shouldn't use obvious identifiers in html, like .honeypot
or .hidden
, as this will be probably easily found by the bot, too. Also, z-index
usually isn't the way to go, as it tells bot "this element is under other one", or "this element is over other one, hides something".