Angel,
Nice work. And, I might mention, the perfect and applicable use for client side Javascript.
One minor addition to your code, if I might.
Code:
function fmt(num, id) {
var phone = num;
if (phone != "") {
phone = phone.replace(/\s|\(|\-|\)|\.|x|:|\*/g, "");
area = "(" + phone.substr(0,3) + ") ";
pre = phone.substr(3,3) + "-";
main = phone.substr(6,4);
if (phone.length > 10) {
ext = " Ext: " + phone.substr(10);
phone = area + pre + main + ext;
} else {
phone = area + pre + main;
}
document.getElementById(id).value = phone;
} else {
document.getElementByID(id).value = num; }
} The additional if/else evaluation keeps us from putting extra chars in fields that were originally empty when we tab through the form. Also placed an extra space after the closing parenthese, cleans it up a smidge as well.
-----------------------
Bookmarks