6

Some folks would like to enter their birth date but would prefer not to divulge the year they were born as it reveals their age ;)

Looks like the Date of Birth field has validation that requires year. What are my options for making year optional?

2
  • 1
    I've had two cases where the client wants the reverse: i.e. year of birth but not the month/day. In those cases, I've just put in Jan 1 and hidden that part of the date. In your case, I wonder if you could do something similar (e.g. put 1970 as the year, but hide it). Definitely a hack. In any case, since the field is storing the data as a mysql date, it's not just a form validation issue. The other option has probably occurred to you - namely a custom field.
    – Alan Dixon
    Commented Apr 7, 2015 at 20:37
  • Yep I will definitely use a custom field if this is not possible on the core Date of Birth field. Thanks for your feedback.
    – LunkRat
    Commented Apr 7, 2015 at 20:39

2 Answers 2

3

This question led me to re-investigate a 'feature' that was added quite a few years back to allow sites to set different date formats for categories of date fields. In 4.6, you access this via Administer > Customize > Date Preferences. There is a 'category' for Birth Date which "should" allow you to select alternative formats including mm/dd OR yyyy.

Unfortunately, testing in 4.4, 4.5, and 4.6 shows that there's a long-standing regression for this functionality (which I guess was rarely used). The Birth Date input field 'appears' to accept dates in the alternate format, but they aren't saved properly in any of the current versions.

Pretty sure fixing this will involve mods to the schema, processing code and the date input widget - so non-trivial. If someone is interested in working on a fix for 4.7 - patches definitely welcome.

2

I have the same issues - Unfortunately, there are only workarounds as Alan mentioned in the comment:

  • Set as a Custom Field
  • Set & Hide the Year portion of the field if age will not be used throughout the system

Not the answer you're looking for? Browse other questions tagged or ask your own question.