This topic is locked

Input Mask

12/27/2006 1:29:13 PM
ASPRunnerPro General questions
J
jtforstner author

Is it possible for me to force phone numbers to be entered into the database in a certain format even though users are entering them without the dashes? (ie: XXXXXXXXXX becomes XXX-XXX-XXXX)
Thanks,
JF

Sergey Kornilov admin 12/27/2006

You can use BeforeAdd/BeforeEdit events to format phone numbers the way you need it.

J
jtforstner author 12/27/2006

You can use BeforeAdd/BeforeEdit events to format phone numbers the way you need it.


Could you please give me a phone # example to work with? Thanks in advance!

Sergey Kornilov admin 12/27/2006

Here you go. Make sure you replace PhoneFieldName with actual field name.

ret = dict("PhoneFieldName")

If Len(ret) = 7 Then

ret = Mid(ret, 1, 3) & "-" & Mid(ret, 4)

Else

If Len(ret) = 10 Then ret = "(" & Mid(ret, 1, 3) & ") " & Mid(ret, 4, 3) & "-" & mid(ret, 7)

End If

dict("PhoneFieldName") = ret