ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 전화 번호 입력 검증 - C
    GUI/컨트롤 2009. 8. 20. 11:57
    bool VerifyPhoneNo(const char *sTelNo_)
    {
        bool bRet = true;

        char *sTelNo=NULL;

        sTelNo = replaceAll2(sTelNo_, "- ", "");
        if (0 == strncmp(sTelNo, "011", 3) || 0 == strncmp(sTelNo, "016", 3) ||
                0 == strncmp(sTelNo, "017", 3) || 0 == strncmp(sTelNo, "018", 3) ||
                0 == strncmp(sTelNo, "019", 3) || 0 == strncmp(sTelNo, "010", 3) )
        {
            if (10 > strlen(sTelNo) || 11 < strlen(sTelNo)) {
                bRet = false;
                goto jump_here;
            }
        } else {
            if (!isdigit(sTelNo[0]) || 10 > strlen(sTelNo) || 11 < strlen(sTelNo)) {
                bRet = false;
                goto jump_here;
            }
        }
    jump_here:
        if (sTelNo)
            free(sTelNo);

        return bRet;
    }

Designed by Tistory.