Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 DEV-Group
 DEV Discussions (General)
 e-mail address validation
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 22 June 2004 :  06:13:22  Show Profile
We just had another person try and register with an e-mail address that included some javascript attempting to steal cookies. Though it won't actually work, I still think we should check for a valid e-mail address instead of letting whatever a user enters.

I was thinking either something like this:

http://www.4guysfromrolla.com/webtech/051999-1.shtml

A javascript validation would be a possibility except javascript can be turned off by the user.

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 22 June 2004 :  06:22:35  Show Profile  Visit HuwR's Homepage
sounds like a good idea to me
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 22 June 2004 :  06:33:55  Show Profile
this is what we are currently using:

function EmailField(fTestString) 
	TheAt = Instr(2, fTestString, "@")
	if TheAt = 0 then 
		EmailField = 0
	else
		TheDot = Instr(cLng(TheAt) + 2, fTestString, ".")
		if TheDot = 0 then
			EmailField = 0
		else
			if cLng(TheDot) + 1 > Len(fTestString) then
				EmailField = 0
			else
				EmailField = -1
			end if
		end if
	end if
end function 
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 22 June 2004 :  07:10:24  Show Profile
Here is what is being used now:

function EmailField(fTestString)
	' checks for a vaild email
	' returns 0 for invalid addresses
	' returns -1 for valid addresses
	dim atCnt
	EmailField = -1

	' chk length
	' a@b.c should be the shortest an
	' address could be
	if len(fTestString) < 5  then
		EmailField = 0

	' chk format
	' has at least one "@"
	elseif instr(fTestString,"@") = 0 then
		EmailField = 0

	' has at least one "."
	elseif instr(fTestString,".") = 0 then
		EmailField = 0

	' has no more than 6 chars after last "."
	elseif len(fTestString) - instrrev(fTestString,".") > 6 then
		EmailField = 0

	' has no "_" after the "@"
	elseif instr(fTestString,"_") <> 0 and instrrev(fTestString,"_") > instrrev(fTestString,"@")  then
		EmailField = 0

	' has only one "@"
	else
		atCnt = 0
		for i = 1 to len(fTestString)
			if  mid(fTestString,i,1) = "@" then
				atCnt = atCnt + 1
			end if
		next

		if atCnt > 1 then
			EmailField = 0
		end if

		' chk each char for validity
		for i = 1 to len(fTestString)
			if not isnumeric(mid(fTestString,i,1)) and _
			(lcase(mid(fTestString,i,1)) < "a" or _
			lcase(mid(fTestString,i,1)) > "z") and _
			mid(fTestString,i,1) <> "_" and _
			mid(fTestString,i,1) <> "." and _
			mid(fTestString,i,1) <> "@" and _
			mid(fTestString,i,1) <> "-" then
				EmailField = 0
			end if
		next
	end if
end function
Go to Top of Page

proeder
Junior Member

Australia
230 Posts

Posted - 23 June 2004 :  04:15:02  Show Profile  Visit proeder's Homepage
	' has no more than 3 chars after last "."
	elseif len(fTestString) - instrrev(fTestString,".") > 3 then
		EmailField = 0


...should be changed to no more than 4 though.

(.info / .name)


Looking for german Snitz forum? Suchst Du ein deutsches Snitz Forum?
Hier findest Du eins...

Hosting with ASP Support available: http://www.sharepointing.com

Edited by - proeder on 23 June 2004 04:16:32
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 23 June 2004 :  04:43:50  Show Profile  Visit Nathan's Homepage
6 (.museum)

Nathan Bales
CoreBoard | Active Users Download
Go to Top of Page

RichardKinser
Snitz Forums Admin

USA
16655 Posts

Posted - 23 June 2004 :  05:24:00  Show Profile
updated the function above, I changed it to check for more than 6 characters after the last .
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 23 June 2004 :  09:22:21  Show Profile  Visit Gremlin's Homepage
Isn't it perhaps time to start considering using RegEx for things like this? would really simplify things if we did.

Kiwihosting.Net - The Forum Hosting Specialists
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 23 June 2004 :  09:29:59  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Since new domains like .museum are sure to come out with a longer length, couldnt we check to make sure that each character after the . does not contain a space or additional . , ; : > < and so on.

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.18 seconds. Powered By: Snitz Forums 2000 Version 3.4.07