b_avery@yahoo.c
25th May 2004 20:37 UTC
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?
deguix
25th May 2004 22:20 UTC
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)).
Coppermill
26th May 2004 13:16 UTC
Working now
Many thanks :-)
j27lee
26th May 2004 19:47 UTC
Coppermill,
would you mind posting the function? I may be doing the same thing pretty soon here.
Thanks,
james
Coppermill
26th May 2004 20:31 UTC
!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"
j27lee
27th May 2004 05:57 UTC
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
Coppermill
27th May 2004 08:46 UTC
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.