I'm using the Date API to show a date field with Month/Day/Year and it is "required" (with no default). If I don't enter anything, the error message appears as follows:

• Month field is required.
• Day field is required.
• Year field is required.
• Field Birthday has errors. The year must be a number between 1 and 4000. The month must be a number between 1 and 12. The day must be a number between 1 and 31.

The "required" messages have already stated what is wrong. The "Field birthday has errors..." message is not needed in this case, and IMHO it just adds confusion to the issue.

The value error check should distinguish between blank (or null) values vs. values that were entered outside the accepted ranges, and show the error message only in the latter case.

Comments

j0e’s picture

I too found it redundant and used string overrides on each of the four individual t strings to craft a custom message relating to the birthday field on my registration form. Here are the t strings from date_api_elements.inc in case someone else wants to do this workaround. (Each line below is a separate t string, so it needs its own individual override).

Field %field has errors.
The year must be a number between %min and %max.
The month must be a number between 1 and 12.
The day must be a number between !min and !max.

chinita7’s picture

Is there any way to hide these 3 messages completely? I tried disable message module but it couldn't hide them.

j0e’s picture

if you put the above lines individually into string overrides and then leave each replacement field blank, i believe they won't appear...it's been a while since i first did it but it worked then

chinita7’s picture

@j0e Yes, it works. Thanks a lot!

j0e’s picture

great, you're welcome

fonant’s picture

Duplicate of #1005182: Required date error message(s) which has a slightly nicer solution, removing the three unnecessary (day, month, year) messages.

DamienMcKenna’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Unfortunately the Drupal 6 version of the Date module is no longer supported. That said, we appreciate that you took time to work on this issue. Should this request still be relevant for Drupal 7 please feel free to reopen it. Thank you.