date input and validate

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

date input and validate

Post by jalz » Tue Dec 17, 2013 11:22 pm

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

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: date input and validate

Post by Klaus » Tue Dec 17, 2013 11:57 pm

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

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: date input and validate

Post by jalz » Wed Dec 18, 2013 11:04 pm

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

Post Reply