Hi
You need not bother about date/time validations.
There is plugin called validates_date. just download & install it.
in your model, add following line and you are done.
validates_date :field_name
Cheers !
Sandip
On Tue, Jun 2, 2009 at 8:59 AM, Erwin
<yves_dufour-ee4meeAH724@public.gmane.org> wrote:
>
> I am trying to find the best way in validating a textfield
> ''start_time'' in a form,
> based on the expected strftime format ("%I:%M%p")
>
> if a user don''t enter the correct format like "
01:45PM" hh:mm in
> 12-hours (with PM/AM ) then should raise an error
> I know it''s possible to validate using gsub , but I wonder if
there is
> any possibility to raise an ArgumentError in parsing the value in a
> Date/Time function...
>
> I tried
>
> start_time = "89"
> t = Time.parse(Time.now.to_date.to_s + "," + start_time)
> but it doesn''t raise an error...
>
> erwin
>
>
> >
>
--
Ruby on Rails Developer
http://sandip.sosblog.com
www.joshsoftware.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---