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 MOD-Group
 MOD Add-On Forum (W/O Code)
 How To Check For Valid Email
 New Topic  Reply to Topic
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

leatherlips
Senior Member

USA
1838 Posts

Posted - 31 July 2008 :  21:54:23  Show Profile  Visit leatherlips's Homepage  Reply with Quote
I have a page where the user enters an email address. What code would I use to make sure the email address is in a valid format? I don't need to verify it. I just want to make sure they enter something like abc@abc.com. If they don't then I want them to receive an error about the email not being valid and to go back and enter a valid one.<

Mangione Magic Forum - The Music of Chuck Mangione

My Mods: Googiespell MOD | Link To Reply MOD | Petition MOD | Contact Page MOD | Share This Topic MOD | MP3 MOD | PageEar MOD | Google Viewer MOD

phy1729
Average Member

USA
589 Posts

Posted - 31 July 2008 :  22:37:23  Show Profile  Reply with Quote
http://www.regular-expressions.info/email.html<
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 31 July 2008 :  23:54:33  Show Profile  Visit AnonJr's Homepage  Reply with Quote
I seem to remember there was a ChkEMail function (or something similar) in inc_func_common.asp. It would be a good place to start...<
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 26 August 2008 :  10:41:23  Show Profile  Reply with Quote
AnonJr: I have had a look through inc_func_common and can not see an email validity check routine. Like you say, I am sure there is a routine, somewhere within the forum, to meet leatherlips requirement. Any further ideas please..<
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 26 August 2008 :  10:56:02  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
Posted sometime ago as a security fix replacement for an existing function in inc_func_member.asp:

function EmailField(fTestString) 
	set regEx = New RegExp
	regEx.Global = true
	regEx.IgnoreCase = true
	regEx.Pattern = "^[A-Z0-9._%-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$"

	retVal = regEx.Test(fTestString)

	set regEx = nothing

	if Not retVal Then
           EmailField = 0
	Else
           EmailField = 1
	end if
end function 
<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 26 August 2008 :  12:09:17  Show Profile  Reply with Quote
thank u ruirib<
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 26 August 2008 :  12:55:49  Show Profile  Reply with Quote
Is there an easy way to link this function Emailfield to my input field:

response.write " <input type=""text"" style=""background-color:#F5FBF1"" name=""frommail"" size=""50"">" & vbNewLine


I have added the function to my inc_func_common and can not see how to tie the functionality together with appropriate error message to be displayed - if a user inputs a wrong email string format


The code I have on the form preview is:
frommail = trim(chkString(request.form("frommail"),"SQLString"))
if frommail ="" then strError = strError & "Please enter your email address!<br>" 'checking for blank email field
if (InStr(Request("tomail"), "@") = 0 or InStr(Request("frommail"), "@") = 0) then strError = strError & "Enter an e-mail address in the form username@domain.co.uk<br></font>"

But is a user puts an email in this format humbug@xmas the routine passes, (that is the code I have)
Thank you andy




<
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20593 Posts

Posted - 26 August 2008 :  13:39:11  Show Profile  Visit HuwR's Homepage  Reply with Quote
The function should replace the existing EmailField function in inc_func_member.asp so you will also need to include inc_func_member.asp

you would then use it like so

if EmailField(frommail) = 1 then
'we passed so do stuff :)
else
'we failed so error
end if<
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 26 August 2008 :  18:28:21  Show Profile  Reply with Quote
Thank u HuwR<
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 26 August 2008 :  19:24:22  Show Profile  Reply with Quote
I currently do not have access to my forum files, but following Huwrs input, would this work:

if EmailField(frommail) = 0 then strError = strError & "Enter an e-mail address in the form username@domain.co.uk<br></font>"
...
..
end if (later)

I have gone for the =0 as all the other error messages have a link underneath to return to input form.<
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20593 Posts

Posted - 27 August 2008 :  01:50:10  Show Profile  Visit HuwR's Homepage  Reply with Quote
yes, that should be fine.<
Go to Top of Page

Andy Humm
Average Member

United Kingdom
908 Posts

Posted - 27 August 2008 :  03:58:40  Show Profile  Reply with Quote
Huwr: Thank you, all works fine now.. next!<
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 29 August 2008 :  06:43:57  Show Profile  Reply with Quote
Thanks, Rui; was looking for a RegEx address validator

<

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 29 August 2008 :  06:56:16  Show Profile  Send ruirib a Yahoo! Message  Reply with Quote
quote:
Originally posted by Shaggy

Thanks, Rui; was looking for a RegEx address validator




No problem . This is not a complete solution, even if it should be fine for "normal" use.<


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

Shaggy
Support Moderator

Ireland
6780 Posts

Posted - 29 August 2008 :  06:59:16  Show Profile  Reply with Quote
Seems to be doing the trick for me so far What problems have you encountered with it?

<

Search is your friend
“I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20593 Posts

Posted - 29 August 2008 :  07:04:13  Show Profile  Visit HuwR's Homepage  Reply with Quote
quote:
Originally posted by Shaggy

Thanks, Rui; was looking for a RegEx address validator





here is better one , the one posted above does not accept all the valid characters for an email address, the one below should.

\w+([!#$%*/?|^{}`~&'+-=_]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*<
Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000 Version 3.4.07