Hello all forum members,
I finally got it to work but not without the expert advice I recieved from Sergey. Thanks Sergey. I will try to explain how to make this work. What I wanted was to format the data with dashes and parens as the user was entering so that they didn't have to add the dashes and/or parens. And yet they could see the properly formatted data as they where entering. For instance, I have a US phone number field. When the user enters the field and begins typing, immediately a "(" is displayed and then the digits the user is entering. After the third digit is entered a ")" and a space are displayed. then after the 6th digit is entered, a "-" is displayed. I did the same for a US social security number.
May be a better way to do this, but it worked for me.
I Decided to store the () and dashes in the database. So I increased the field size on the phone #'s from 10 to 14 and ssn from 9 to 11 in the database.
Next I went to http://www.vicsjavascripts.org.uk/FormComp...ormatNumber.htm and downloaded the script. Thanks Vic, great script. I READ the docs at the top of the script so I knew what it was doing and what I needed to change.
I then created a file in the ./include directory call myapp_js.php and copied Vic's script into it.
In ./include/.._functions.php I made the following edits:
Changed the max len setting for the phones to 14 and ssn to 11 in include/.._functions.php under "function GetEditParams"
Added this to the top of function.php
include("include/myapp_js.php");
Edited this section of code in the same file.
FROM
if($format==EDIT_FORMAT_TEXT_FIELD)^M
{^M
if(IsDateFieldType($type))^M
return '<input type="hidden" name="type'.$ifield.'" value="date'.EDIT_DATE_SIMPLE.'">'.GetDateEdit($field,$value,0,$ifield,$edit);^M
return '<input type="text" name="value'.$ifield.'" '.GetEditParams($field).' value="'.htmlspecialchars($value).'">';^M
}^M
TO
if($format==EDIT_FORMAT_TEXT_FIELD)
{
if(IsDateFieldType($type))
return '<input type="hidden" name="type'.$ifield.'" value="date'.EDIT_DATE_S
IMPLE.'">'.GetDateEdit($field,$value,0,$ifield,$edit);
if ($field=="Home_Phone" || $field=="Work_Phone" || $field=="Spouse_Work_Phone")
return '<input type="text" name="value'.$ifield.'" '.GetEditParams($field).' value="
'.htmlspecialchars($value).'";
onkeyup="f20FormatNumber(this,\'(~) ~-~~~~\',\'Blur\');" >';
if ($field=="SSN" || $field=="Spouse_SSN")
return '<input type="text" name="value'.$ifield.'" '.GetEditParams($field).' value="
'.htmlspecialchars($value).'";
onkeyup="f20FormatNumber(this,\'~--~~~~\',\'Blur\');" >';
if ($field=="Spouse_DOB")
return '<input type="text" name="value'.$ifield.'" '.GetEditParams($field).' value="
'.htmlspecialchars($value).'";
onkeyup="f20FormatNumber(this,\'//~~~~\',\'Blur\',[\'mm/dd/yyyy\',,]);" >';
// DRH 8-31-06 The following line must be the last after all the f20FormatNumber Calls
return '<input type="text" name="value'.$ifield.'" '.GetEditParams($field).' value="
'.htmlspecialchars($value).'">';
}
It works perfectly. I haven't got the DATE format to work yet, not sure I am going to. Sergey recommended I not, but I am still slightly interested in it. Time allowing, I might take another stab at it.
I am not the best note taker, but I don't believe I left out any steps. This worked great for me.
Thanks to all that read my post, and special thanks to those who responded.
Dave