validate.cpp

来自「使用短信猫可以实现短信的群发」· C++ 代码 · 共 58 行

CPP
58
字号
// Validate.cpp: implementation of the CValidate class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "sms.h"
#include "Validate.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CValidate::CValidate()
{

}

CValidate::~CValidate()
{

}

BOOL CValidate::IsDigitAndAlpha(CString & str)
{
	int i=0;
	for(;i<str.GetLength();i++)
	{
		if(isdigit(str[i]) || isalpha(str[i]))
		{
			continue;
		}
		else
		{
			return FALSE;
		}
	}
	return TRUE;
}

BOOL CValidate::ValidatePhone(const CString &str)
{
	int length = str.GetLength();
	for (int i=0; i<length; ++i)
	{
		if (!(isdigit(str[i]) || (str[i] == '+' && i == 0)))
		{
			return FALSE;
		}
	}
	
	return TRUE;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?