Function "IsValidMailAddr" is doing weird
#2

I do not have the answer to your exact problem but I tried building my own IsValidEmail modeled after yours and tested it using your 4 emails. You could probably compare my function with yours and find out the problem.

Function:
pawn Код:
stock IsValidEmail(email[])
{
    new a_count, length = strlen(email);
    if(length < 5)
        return false;
    for(new i = 0; i < strlen(email); i++)
    {
        if(email[i] == '@')
        {
            a_count++;
            if(a_count > 1)
            {
                return false;
            }
        }
        if( (email[i] < 'A' && email[i] > 'Z') || (email[i] < 'a' && email[i] > 'z') )
        {
            if(email[i] != '.')
            {
                return false;
            }
        }
        if(i == length-1 && email[i] == '.')
            return false;
    }
    return true;
}
Test code:
pawn Код:
printf("%d", IsValidEmail("kwarde@rpdsamp.nl"));
printf("%d", IsValidEmail("kwarde@rpdsamp.nl."));
printf("%d", IsValidEmail("kwa*de@@rpdsamp.nl"));
printf("%d", IsValidEmail("kwarde@rpdsamp.nl"));
Test Results:
1 = true
0 = false
Код:
1
0
0
1
Reply


Messages In This Thread
Function "IsValidMailAddr" is doing weird - by Kwarde - 10.02.2011, 18:29
Re: Function "IsValidMailAddr" is doing weird - by Krx17 - 10.02.2011, 20:46
Re: Function "IsValidMailAddr" is doing weird - by Kwarde - 11.02.2011, 04:36
Re: Function "IsValidMailAddr" is doing weird - by Krx17 - 11.02.2011, 04:39
Re: Function "IsValidMailAddr" is doing weird - by Kwarde - 11.02.2011, 05:01
Re: Function "IsValidMailAddr" is doing weird - by Kwarde - 11.02.2011, 05:11

Forum Jump:


Users browsing this thread: 2 Guest(s)