Datetime_select validation

I’m using a datetime_select. When I select an invalid date like 31
february 2007 it’s received by the model as 3 march 2007. I would like
to generate a nice error for the user, but the only option I see now is
hack this into the controller. Not so nice…

Joep Mathijssen

Hi Joep,

if you’re using datetime_select to set a DateTime property in your
model, then you might want to consider using the pluging from Jonathan
Viney available at:


This plugin can validate dates and times with some extra constraints
(:before, :after, …) for properties of your model. There are some
small examples at:

You may want to replace the parse_date function in parser.rb with the
one from Matt G. explained at:

If you only want to select dates then you’re better off with

Kind regards,


Hi, please search this group because I have answered this question.

Good luck,