Date / Time validation?

22 views
Skip to first unread message

Open individual

unread,
Oct 8, 2007, 5:08:03 AM10/8/07
to Ruby on Rails: DHTML Calendar
Hi everyone,

To make a long story short.

I have integrated DHTML calendar with Active Scaffold.

Right now I can't get date/time validation working with Active
Scaffold 100%.

Has anyone got this working or approaches it in a different way?

I have been stuck the whole weekend on this issue.

I had a look at Ed Moss's great Demo.

He has the same concept that I and the rest of the developers out
there would like to do.

I see he has a similar problem with date/time validation as I am still
able to enter in text and select the create button.

His Demo as of 08 October 2007 is a lot more robust than mine as it
allows does not render an error when text (eg "Hello") is entered
enter the date field and create button is pressed.

The problem is that I would like to display an active scaffold message
stating that the date is not in a recognized format.

Has anyone succeeded in this or tried another approach and got it
working?

I am currently using PostGreSQL.
You will be pleased to know that Ed Moss has made it compatible
between PostGreSQL and MySQL.

Also I see that Ed has stuck to the default ISO 8601 date time format

http://www.cl.cam.ac.uk/~mgk25/iso-time.html

YYYY-MM-DD HH:MM:SS.
eg 1995-12-30 23:59:59

Excellent.
The PostGreSQL DB date field defaults to this standard now when
installed.
I see that this is now and new standard for the date and many
companies are now enforcing it.

If I can just get the date field in to validate date/time entries then
it will be great.

Regards
Uncle Mike

Open individual

unread,
Oct 9, 2007, 5:05:33 AM10/9/07
to Ruby on Rails: DHTML Calendar
Has anyone got this date validation to work?

If so can you please let me know cause I am a little stuck at the
moment.

Ed Moss

unread,
Oct 26, 2007, 12:00:12 PM10/26/07
to Ruby on Rails: DHTML Calendar
I think I have a possible solution. I will post it to the trunk
shortly.

Ed Moss

unread,
Oct 26, 2007, 4:20:43 PM10/26/07
to Ruby on Rails: DHTML Calendar
The challenge here is DHTMCalendar allows string input such as
"today", and the .js is not completely validating input.
Eventually, it would be nice to have the .js validate every possible
condition for input. Until then, we need to handle the condition where
a bad value was input.

To that end the plugin now returns a value that can be validated
against as being a bad value in a in the form of 0000-01-

Add something like the following to your validate method in your
model:
errors.add :funding_on, "Funding date must be after 1-1-2000." if
funding_on and (funding_on < Date.new(2000,1,1))

This is now in trunk. Let me know what you think.

Reply all
Reply to author
Forward
0 new messages