shadowayex Posted October 6, 2009 Share Posted October 6, 2009 I've used PHP regular expressions before, and I've seen email verification done with them before. I'm trying to accomplish a similar effect browser-side.I think I have something, but I want opinions to make sure that I've got something good.I started with this: var email = document.getElementById("email").value;var regexp = new RegExp(".+@.+\\..+");if(email.search(regexp) == -1){ alert("fail");}else{ alert("pass");} That searched to make sure that @something.something existed in the email address. But that allowed email addresses like m@m.m to pass. So I kicked it up a notch. I've only seen the .somethings to be as short as 2 characters (.tv) and as long as 5 (.com.au). So I editted to to take a minimal of 2 characters after the dot: var regexp = new RegExp(".+@.+\\...+); But users could still put m@m.mm or something like that. I'm thinkng that's the best I can do and if users don't put a real email address then so be it.I plan on setting up a mail server and using PHP's mail() feature for email verification (make them click a link to activate the account and whatnot). Is this the best I can do? Or is there more browser-side tests that can be done?Edit: Fixing minor mistakes Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.