/*------------------------------------------------------------------------------ * 1. ÆÄÀϸí: biz.js * 2. ¼³ ¸í: ÀÏÀÚ¸¦ Æ÷ÇÔÇÑ ±âº»ÀÚ·áÇü ¿ÜÀÇ ¾÷¹« ÀÚ·áÇü ¹× ¾÷¹«·ÎÁ÷À» ó¸®ÇÏ´Â * ÇÔ¼ö¸¦ Á¤ÀÇÇÑ´Ù. * 3. ÀÇÁ¸¼º: string.js * 4. ÀÛ¼ºÀÚ: * 5. ÀÛ¼ºÀÏ: 2006.10.16. -----------------------------------------------------------------------------*/ /** * ÀüÈ­¹øÈ£ °ªÀ» Çü½ÄÈ­ÇÑ´Ù. */ function formatTelNo(phoneNo) { if ( isEmpty(phoneNo) ) return ""; var hasLocalNo = ( phoneNo.length >= 9 && phoneNo.length <= 11 ); var formattedNo = ""; // Çü½ÄÈ­µÈ ¹øÈ£. /* Áö¿ª¹øÈ£°¡ À¯¹«¿¡ µû¶ó ó¸®. */ if ( hasLocalNo ) { /* Áö¿ª¹øÈ£°¡ ÀÖÀ» ¶§. */ /* Áö¿ª¹øÈ£°¡ 02Àΰ¡? */ if ( phoneNo.indexOf("02") == 0 ) { formattedNo = "02-" + ( phoneNo.length == 9 ? phoneNo.substr(2, 3) : phoneNo.substr(2, 4) ) + "-" + phoneNo.substr(phoneNo.length - 4); } else { formattedNo = phoneNo.substr(0, 3) + "-" + ( phoneNo.length == 10 ? phoneNo.substr(3, 3) : phoneNo.substr(3, 4) ) + "-" + phoneNo.substr(phoneNo.length - 4); } } else { /* Áö¿ª¹øÈ£°¡ ¾øÀ» ¶§. */ formattedNo = ( phoneNo.length == 7 ? phoneNo.substr(0, 3) : phoneNo.substr(0, 4) ) + "-" + phoneNo.substr(phoneNo.length - 4); } return formattedNo; } /** * ÁÖ¾îÁø ObjectÀÇ °ªÀ» ÀüÈ­¹øÈ£·Î °¡Á¤Çϰí Çü½ÄÈ­ÇÑ´Ù. */ function formatTelNoObj(obj) { obj.value = formatTelNo(obj.value); } /** * ÇÚµåÆù ¹øÈ£ °ªÀ» Çü½ÄÈ­ÇÑ´Ù. * ³Ñ¾î¿Â ¹øÈ£ °ªÀº À¯È¿ÇÑ ÇØµåÆù ¹øÈ£ÀÓÀ» °¡Á¤ÇÑ´Ù. */ function formatHpNo(phoneNo) { /* °ªÀÌ ¾ø´Â °æ¿ìµµ À¯È¿ÇÑ °ªÀÌ´Ù. */ if ( isEmpty(phoneNo) ) return ""; /* ±×·¡µµ Ȥ½Ã ¸ð¸£´Ï ±æÀ̸¦ È®ÀÎÇØ º¸ÀÚ. */ var hpNo = removeChar(phoneNo, "-"); if ( hpNo.length != 10 && hpNo.length != 11 ) { showSysMessage("hpNoÀÇ °ª [" + phoneNo + "]´Â - ¸¦ »« ±æÀ̰¡ 10À̳ª 11À̾î¾ß ÇÕ´Ï´Ù."); return phoneNo; } /* ¾Õ¿¡¼­ 3ÀÚ¸® Áö¿ª¹øÈ£. */ var formattedNo = hpNo.substr(0, 3) + "-"; /* Àüü ±æÀ̰¡ 10À̸é 3ÀÚ¸®°¡ ±¹¹ø, 11À̸é 4ÀÚ¸®°¡ ±¹¹ø. */ formattedNo += ( hpNo.length == 10 ? hpNo.substr(3, 3) : hpNo.substr(3, 4) ) + "-"; /* ³ª¸ÓÁö 4ÀÚ¸® ¹øÈ£. */ formattedNo += hpNo.substring(hpNo.length - 4); return formattedNo; } /** * ÁÖ¾îÁø ObjectÀÇ °ªÀ» ÇÚµåÆù ¹øÈ£·Î °¡Á¤Çϰí Çü½ÄÈ­ÇÑ´Ù. */ function formatHpNoObj(obj) { obj.value = formatHpNo(obj.value); }