kangus
|
| Posted: 08/15/2002, 12:53 AM |
|
While cleaning up a project I started to add all the normal stuff expected of an application, user input validation and display formatting. Surprise! You can not set the display format for anything but Date and Boolean data types, if you capture zip+4 or areacode+phone and store it as a number you'll have to write your own Before Show Event to format the zip code. Below is my try at formatting a phone number:
(NOTE: If there is an easier way LET ME IN ON IT!)
function contact_HomePhone_BeforeShow() { //contact_HomePhone_BeforeShow @40-A09891F1
//Custom Code @48-2A29BDB7
// -- four tests: no number - 7 digit number - 10 digit number and invaild
// number -- US based numbers only
global $contact;
$tmp = $contact->HomePhone->Value;
$phoneLen = strlen($tmp);
if ($phoneLen < 1)
{
$noPhone = $contact->HomePhone->SetValue("Unavailable");
}
elseif ($phoneLen == 7)
{
$phoneOnly = $contact->HomePhone->SetValue((substr($tmp,0,3)."-" . substr($tmp,3,4)));
}
elseif ($phoneLen == 10)
{
$areaCodePhone = $contact->HomePhone->SetValue(("(" . substr($tmp,0,3) . ") " . substr($tmp,3,3)."-" . substr($tmp,6,4)));
}
else
{
$invaildNumber = $contact->HomePhone->SetValue("Invaild Number");
}
unset($tmp);
unset($phoneLen);
/ -------------------------
//End Custom Code
} //Close contact_HomePhone_BeforeShow @40-FCB6E20C
|
|
|
 |
Ron
|
| Posted: 08/16/2002, 12:32 AM |
|
Hello,
I've added mask for the phone field on the grid form just typed it in into Format property field: (###) ###-####. The field type is set to Integer.
|
|
|
 |
|