Archive: email validation


email validation
Is is possilbe to do some email validation on a string?

I've seen some PHP:

function validEmail($email) {
if (eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]
{2,4}", $email)){
return TRUE;
} else {
return FALSE;
}
}

which would do the job, but not sure how to implement it into NSIS.

Any one help?

Or does anyone know how to make sure the user enters a valid e-mail address?


Yes, it possible, but you have to make a function for it, because we don't have any in the Archive.

To do a simple, basic detection, you can use "${StrStr}" (from StrFunc.nsh) to detect if there is a character that should (or shouldn't) be there (as "@", "." (which should be there) and i.e. ">", "^" (which shouldn't be there)).


Working now

Many thanks :-)


Coppermill,

would you mind posting the function? I may be doing the same thing pretty soon here.

Thanks,

james


!include "StrFunc.nsh"

${StrStr}

;Simple validate for an E-mail address, checking for @ followed by .

${StrStr} $0 "name@Domain.com" "@"

${StrStr} $0 $0 "."

StrCmp $0 '' +1 +2
MessageBox MB_OK "Not a valid e-mail address"


Thanks

i thought you had done the other character checks and stuff too. I haven't decided whether i'm going to do that in nsis, or serverside for my installer yet, but if I do go the nsis route, i'll post it.

james


I also use the Validate routine, as in the Archive.

But all a new definition of EMAIL

!Define EMAIL "abcdefghijklmnopqrstuvwxyz 1234567890@_-@."

This way it captures and makes sure only valid characters are entered.