Page 1 of 1

date input and validate

Posted: Tue Dec 17, 2013 11:22 pm
by jalz
Hi Guys,

Im creating a database application and working on various data entry cards. one of the things I need to do is validate data entered in certain fields is formatted correctly. One such type of data is dates. What is the most efficient way (also the simplest for a newbie) to have an input mask on a field which can accept a dd/mm/yyyy format? I'm using the DatePicker extension, so 9 times out of 10, dates will be correct, but I need to be aware that a user may type in a date and I need to make sure its in xx/xx/xxxx format. Any help would be much appreciated

Thanks all
Jalz

Re: date input and validate

Posted: Tue Dec 17, 2013 11:57 pm
by Klaus
Hui Jaz,

you could script a "closefield" handler whcih checks the content.
Quick & dirty example:

Code: Select all

on closefield
   put me into tContent

 ## 1. check for correct items
   set itemdel to "/"
   if the num of items of tContent <> 3 then
      answer "Idiot!"
     put empty into me #or any other punishment
     exit closefield
  end if

  ## OK Now check the three items:
   if the num of chars of item 1 of me <> 2 then
    ### Wrong day format, hurt user NOW!
   end if
    ## etc......
end closefield
You get the picture :D


Best

Klaus

Re: date input and validate

Posted: Wed Dec 18, 2013 11:04 pm
by jalz
Hi Klaus,
Thank you, how do you remember all this stuff :D
Certainly put me on the right track, including another post you replied to for someone else. Much appreciated.

Jalz