Gotta love old threads if you can find them! Interestingly, there is not an XD smart field to help format text input like there is for dates and such
See: Xdialog Smart Fields.
Although you could use %P=ui_get_text() to add the format string - it pops up another dialog.
So this is my modification to see a SSN formatted as the user types it in:
Code:
dim vSSN as c
vssn=""
Result = ui_dlg_box("Format SSN",<<%dlg%
{region}
SSN:| [.20vSsn!evSsn_*]
{endregion};
{region}
<*15&OK> <15&Cancel>
{endregion};
%dlg%,<<%code%
if a_dlg_button = "evssn_change" then
vSSN = mask(remspecial(vSSN)," - - ")
end if
'----------------
if a_dlg_button = "&OK" .or. a_dlg_button = "&Cancel" then
trace.WriteLn("SSN = " + var->vSSN)
'do nothing, dialog will close
else 'the event has not been handled, so set a_dlg_button to "" to keep the dialog open
a_dlg_button = ""
end if
%code%)
end
If you add the %N% directive, the killfocus event could be used, but you would only see the change when the control loses focus. And without the %N% directive you won't see the killfocus event do anything...
By using the change event and remspecial() in conjunction with the mask(), the control updates properly. And now that area codes are required for dialing all phone numbers, this could easily be adapted for that use too.
Edit: Just noticed that Xdialog was spelled wrong - probably explains why this thread was so hard to find!
Bookmarks