SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Divisive Cotton's Avatar
    Join Date
    Jun 2008
    Location
    Andy lives in London, UK
    Posts
    393
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hidden field in form

    I've been adding a field into forms and then hiding it with display: none

    If a spam bot comes across the form it automatically fills in the field and which is then rejected after validation

    For the purpose of stopping spam bots it seems to be pretty successful

    However, how does this level with accessibility? Any advice is welcome.
    Let everyday be Christmas

  2. #2
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    586
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow thats a good idea to fight spam bots.
    Don't Panic

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,598
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Divisive Cotton View Post
    I've been adding a field into forms and then hiding it with display: none

    If a spam bot comes across the form it automatically fills in the field and which is then rejected after validation

    For the purpose of stopping spam bots it seems to be pretty successful

    However, how does this level with accessibility? Any advice is welcome.
    display:none will only impact people using browsers that don't process the stylesheet. For those people displaying a label for the field explaining that they should leave the field blank as it is there as a trap for spammers should ensure accessibility for those users.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    Follow: @AlexDawsonUK silver trophybronze trophy AlexDawson's Avatar
    Join Date
    Feb 2009
    Location
    England, UK
    Posts
    8,111
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    It should be fine, screen readers tend to ignore anything using display: none so they would skip over the hidden field (which is of no use to them anyway).

  5. #5
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,233
    Mentioned
    47 Post(s)
    Tagged
    1 Thread(s)
    Uh, no. JAWS can ignore display: none when it comes to labels and other special circumstances. I hate they did that, but whatever. Labels get read out... I'd have to go back and check Juicy Studio to see if Window Eyes did that too.

    *edit only problem with it is the age, but my JAWS10 reads out display: none labels still: http://juicystudio.com/article/scree...splay-none.php

    For those people, displaying a label for the field explaining that they should leave the field blank as it is there as a trap for spammers should ensure accessibility for those users.
    Amen, nothing more frustrating for humans than to be accidentally considered a spammer : )

    If I make a post on the Fronteers site, they use Javascript to hide a question. Since i don't have that on, I get an extra field. The label says "NEE invullen" (fill in NO) but I misread it and thought it said "NIET invullen" (don't fill in) so I kept triggering the spam filter, lawlz. This can also work since most bots don't process Javascript.

    On a moving site I haz:
    Code:
    <label for="spamz" id="spamvraag"><span>AUB <strong>Niet invullen</strong>, dit is een anti-spam vraag:</span>
    <input type="text" id="spamz" name="spamz" title="aub niet invullen!"></label>
    Title is an extra to really catch any screen reader users who have titles on, though it does trigger that old W-E bug where inputs inside labels aren't focussable... then again, for this question, that's just fine : )

    One thing I might want to look out for are smarter bots who might be scanning the label for the word "spam" though. I mean, if I made such bots I'd consider adding something like that : )


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •