on rawkeyup
put numtochar(47) after char 2 of field "field"
end rawkeyup
Birthdate
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Birthdate
I am trying to create a dynamic birthdate field in my app. I have a field the user can enter data into but in my testing I am doing something terribly wrong. I'd love to make the date look like 09/01/2011 when the user types in the field 09012011. I started testing by adding a / after the first two chars entered. However it just keeps putting / in always. Any ideas on what I'm doing wrong? Thanks!!!!
Re: Birthdate
Code: Select all
on rawkeyup
put the number of chars of field "field" into fieldnum
if fieldnum = 2 then
put numtochar(47) after char 2 of fld "field"
else if fieldnum = 5 then
put numtochar(47) after char 5 of fld "field"
end if
end rawkeyup
Re: Birthdate
Hi Kaubs,
I don't know if this is the best way (probably not), but it is what I have been using.
In the field script try:
regards,
jharris
I don't know if this is the best way (probably not), but it is what I have been using.
In the field script try:
Code: Select all
on keyDown keyName
local tText
-- Code to format the text as a date
if (keyName is a number) and (the length of me < 10) then
if the length of me = 2 then
put "/" into the selection
end if
if the length of me = 5 then
put "/" into the selection
end if
pass keyDown
end if
end keyDown
jharris
Operating System: macOS Monterey Version 12.5
LiveCode Version: 9.6.8
LiveCode Version: 9.6.8
Re: Birthdate
Thanks a ton! The keydown message worked a lot better than rawkeyup. It allows for the delete function I couldn't pass lol.