[Seaside] Magic Date by Simon Willison

Yar Hwee Boon hboon at motionobj.com
Tue Nov 2 20:59:15 CET 2004


On Tue, 2 Nov 2004 12:23:20 +0100, Avi Bryant <avi at beta4.com> wrote:

> A few things I've noticed:
> - it gives an error if passed nil dates and times; it should show an  
> empty text input for this
> - if you modify it to fix the above, and then focus/unfocus the empty  
> text input without typing anything, it treats that as invalid input  
> rather than no input

Thanks for the feedback. I don't see an error though, only getting a "nil"  
value in the textbox. Anyway, I've modelled this behavoir after  
#dateInputWithValue:callback:, ie. a similar error is raised if you pass a  
nil to #dateInputWithValue:callback: and my implementation of  
#dateInputOn:of: which detects a nil value and set it to the current date.  
I guess they are different, because magic date implies a nil-able date,  
while #dateInputWithValue:callback: doesn't. I have attached a modified  
version that sets nil date/time to a blank string instead.

> - if you submit without unfocusing the input, the client-side parsing  
> doesn't happen, and the server-side parsing is less robust

Should be fixed. I only tried on IE6 and Opera (windows) though, can  
someone help test it on Safari and Mozilla/Firefox? I had to use some  
Javascript to attach a handler on for submit to parse the date/time, so  
older browsers might fail. When a date or time is invalid, and submitted,  
I set it to a nil. This has the undesirable side-effect that if you do any  
submit (including validation), all errorenous date/time fields will be  
reset to a blank value. Does anyone has a better alternative? Thanks.

-- 
Regards
HweeBoon
MotionObj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HB-magicdateandtime.2.cs
Type: application/octet-stream
Size: 13505 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/seaside/attachments/20041103/3d7910bc/HB-magicdateandtime.2-0001.obj


More information about the Seaside mailing list