...

View Full Version : Email and form validation script



RalphTrentacost
10-23-2002, 06:06 PM
Does anyone have a script that will validate required fields as well as a correct email format on a form?

Thanks,
Ralph

beetle
10-23-2002, 06:13 PM
I DO! I DO! (http://www.peterbailey.net/fValidate)

zoobie
10-23-2002, 06:14 PM
Look here (http://www.hotscripts.com/JavaScript/Scripts_and_Programs/Forms/). :D

beetle
10-23-2002, 06:29 PM
Originally posted by zoobie
Look here (http://www.hotscripts.com/JavaScript/Scripts_and_Programs/Forms/). :D I'm #9 on that list...and climbing! :D

RalphTrentacost
10-23-2002, 07:42 PM
Is there any more documentation on it other then the web site. Not too sure how it works.

Ralph

beetle
10-23-2002, 07:55 PM
I used to maintain a text-file (readme style) document, but between fValidate development, maintaining the website, plus developing my future projects, full-time job, my 2 year old...etc etc - keeping that text document current was impossible, and subsequently cut from my priority list.

You can contact me directly with the contact form (http://www.peterbailey.net/fValidate/site.php?page=contact) on the website

I will give you any support you need, although I suggest you give the API (http://www.peterbailey.net/fValidate/site.php?page=api) a quick readthrough

Cheers :D

whammy
10-24-2002, 03:03 AM
You can't really validate an email address... unless you send an email to it and make sure it's answered.

Beetle and I had a long discussion about this, and we agree.

The best thing you can do is make sure that the user's email address at least matches a basic email regex, like:

^[\w\+\\'\.-]+@[\w\\'\.-]+\.[a-zA-Z]{2,}$

And yeah, apparently + signs AND single quotes are allowed before the @ sign, and you can have a single quote after that (probably because of some screwy email provider)... it blew me away when a customer emailed us kinda ticked off because his email address was similar to:

Bob+O'Reilly@some'server.co.uk

wasn't valid according to usual email validating regular expressions ((the co.uk wasn't a problem...) and I originally stole the one above from perl, since I figured those guys had a lot of experience with them...).

I've run into a lot of problems with trying to validate "valid" email addresses, I used to use jkd's regex, but that rejected a lot of valid email addresses.

Besides, I can enter billgates@microsoft.com and it will match any regular expression available for valid email addresses. Your best bet is just to use validation to make sure noone has entered a really bad typo (or "asdf"), and they answer your email. :D

beetle
10-24-2002, 03:14 AM
Hey Whammy...I remember our email validation discussion...something I'd like to share...

After said discussion, I decided to look up the RFC specs to determine exactly what IS valid and what is not. After looking for about 30 minutes, I realized why nobody really knows what is valid. Trying to extract any useful meaning from those specs was roughly equivalent to me reading Mandarin Chinese. Upside-down. And drunk. Really...it is pure technical documentation, and I think, not designed to be usable by anyone, but exists merely just to exist.

So, in short, the regex you've got is JUST fine :D

whammy
10-25-2002, 01:02 AM
Yeah, it's working ok. I know what you mean, since I did some research on it myself, and basically from what I gather (and I also felt like I was reading Mandarin Chinese while drunk and upside down) an email address theoretically allows anything in a valid *NIX filename... so really it depends on the provider, etc.

Until I find out there are OTHER even STRANGER legal characters in an email address (which at this point wouldn't surprise me!), I'm sticking with that as well. :)

The main advantage I have is I use the above regular expression for a customer service application I wrote, in which customers for several clients (that in total receive several MILLIONS of NON-SPAM (email newsletters) emails per month) will respond to the customer service department of the company. And if something doesn't work, the CS rep lets me know right away.

So when there's a problem, I find out about it pretty quickly. ;)

beetle
10-25-2002, 03:12 AM
Originally posted by beetle
...but exists merely just to exist.I can't believe missed an opportunity to use one of my favorite words: existential (http://www.dictionary.com/search?q=existential). :rolleyes:

Deanimal
10-25-2002, 05:10 AM
Talk about good timing. I just started learning about validation yesterday so this thread will help a lot.

Posted a question about the url part today:
http://www.codingforums.com/showthread.php?s=&threadid=8593
which I think is close to being resolved.

I considered making my script's email part work better, but then decided it's good enough for now. Figured as long as the user is allowed to leave it blank (for me it's optional) then they're less likely to enter a fake one.

Reading what you wrote above *validates* my decision. (ha!)
Thanks for all the help,



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum