Re: challange
- Posted by Irv Mullins <irvm at ellijay.com> Aug 24, 2001
- 455 views
On Friday 24 August 2001 10:33, George Walters wrote: > > I've taken a cut (not a very good one) to print a date mask into a editText > field and use onChange() to collect what is typed into the field and wrap > the numbers around the slashes. See if you can do a better job than me. If > you can't maybe you can use the rtn. > > It does not validate that what is entered is a date. That woud have to be > done with a onLostFocus() event. This just collects the numbers. Here's one that might work. It ignores anything but 0..9, and adds the / 's at the appropriate places. It could be extended to accept short numbers separated by slashes, i.e. 1/2/01. -- code generated by Win32Lib IDE v0.10.5 include Win32lib.ew without warning procedure EditText2_onChange () object text integer lastchar,x onChange[EditText2] = nil -- don't respond to change events. text = getText(EditText2) if length(text) > 0 then lastchar = text[length(text)] x = find(lastchar,"0123456789") if x > 0 then if length(text) = 2 or length(text) = 5 then text &= "/" end if else text = text[1..length(text)-1] end if end if setText(EditText2,text) setIndex(EditText2,-1) -- done with changes, reenable event trap: onChange[EditText2] = routine_id("EditText2_onChange") end procedure onChange[EditText2] = routine_id("EditText2_onChange") WinMain( Window1, Normal )