Proper Field Validation Methods and other annoyances...

Sarah Reichelt sarah.reichelt at gmail.com
Tue Aug 14 18:01:20 EDT 2007


> 1) Why does  put "4" is a date return true?  If this function doesn't
> actually work, why is it still available?  I'd like to be able to have
> users enter a date without any kind of punctuation (i.e., 08142007) and
> be able to validate it as a valid date.  The same applies to entering
> 1315 as a time (no colon).

My preferred method of date validation is to convert the date to
another format, then convert it back. If I get the same answer both
times, then the date works. Here is a rough example:

function checkDate pDate
  put pDate into tCheck
  convert tCheck to dateItems
  if the number of items in tCheck <> 7 then return false
  convert tCheck to short date  -- edit this to the format you are
sending to the function
  if tCheck = pDate then
     return true
  else
     return false
  end if
end checkDate

HTH,
Sarah



More information about the use-livecode mailing list