T O P I C R E V I E W |
leatherlips |
Posted - 31 July 2008 : 21:54:23 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.< |
15 L A T E S T R E P L I E S (Newest First) |
Shaggy |
Posted - 29 August 2008 : 09:16:34 Thanks, again, Huw; will add that to the script when I get back on the other machine.
< |
HuwR |
Posted - 29 August 2008 : 07:54:51 sorry, another tweak, this should be much better
[A-Z0-9!#$%*/?|\^{}`~&'+-=_]*@\w+([-.]\w+)*\.\w+([-.]\w+)*< |
HuwR |
Posted - 29 August 2008 : 07:46:04 actually mine needs a slight adjustment
\w*([!#$%*/?|\^{}`~&'+-=_])*\w*@\w+([-.]\w+)*\.\w+([-.]\w+)*
it was not allowing this address a!#$%&'*+-/=?@example.com which believe it or not is perfectly valid.
there are still a few cases that won't validate, but they would be very unusual.< |
ruirib |
Posted - 29 August 2008 : 07:27:10 Yes, Shaggy, I guess that was the one.< |
Shaggy |
Posted - 29 August 2008 : 07:15:20 Thanks, Huw; have replaced the RegEx with your one. Looks like this was the source of your one, Rui - some interesting, over-the-top alternatives in that article.
< |
ruirib |
Posted - 29 August 2008 : 07:05:45 I haven't had problems. I got it from a book or online and I remember that it stated that a couple "obscure" cases weren't contemplated. I can't remember what cases were not contemplated, but they were not relevant enough to justify a much more complex regex.< |
HuwR |
Posted - 29 August 2008 : 07:04:13 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+)*< |
Shaggy |
Posted - 29 August 2008 : 06:59:16 Seems to be doing the trick for me so far What problems have you encountered with it?
< |
ruirib |
Posted - 29 August 2008 : 06:56:16 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.< |
Shaggy |
Posted - 29 August 2008 : 06:43:57 Thanks, Rui; was looking for a RegEx address validator 
< |
Andy Humm |
Posted - 27 August 2008 : 03:58:40 Huwr: Thank you, all works fine now.. next!< |
HuwR |
Posted - 27 August 2008 : 01:50:10 yes, that should be fine.< |
Andy Humm |
Posted - 26 August 2008 : 19:24:22 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.< |
Andy Humm |
Posted - 26 August 2008 : 18:28:21 Thank u HuwR< |
HuwR |
Posted - 26 August 2008 : 13:39:11 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< |