I need people who register on my website to enter their year of birth and if necessary confirm that they are over 18. I don't need the whole date of birth and I believe it would discourage registrations if I asked for it.
yearCurrent = the year now
yearOfBirth = the user's year of birth
There should be a drop-down year selector menu that is automatically populated with years from yearCurrent-18 descending to 1901. So in 2010 the menu would be from 1992 to 1901.
As you can see, someone born on June 1 1992 will be 17 at the start of 2010 and 18 after June 1.
So if the user selects a yearOfBirth that indicates that they are either 17 or 18, a pair of radio buttons named 'adult' should appear where they can indicate age 17 or 18.
If they click '17', then text should appear "This site is for over-18s only."
If the user is unambiguously over 18, (yearCurrent - yearOfBirth > 18) these radio buttons should not appear but there should be a hidden field also named 'adult' with a value of '1'.
I would like this to drop into my form as a unit so there is no code before the form and none after. This really does make things simpler for me.