check if email address really exists with a service via ajax (not regularexp) real time if it reallly exists
I like to check the validation of an email address with ajax by onblur? (asp.net,c# and...json or anyother I don't know)
I thought it could be possible with json and calling a webservice. but are there any (free)services to call? 开发者_JS百科or I have to write my own? Hope you understand me what I want.
Thanks
If you just want to validate the format of an email address, you can do it using regular expressions in javascript without having to do any ajax calls. Check out this related thread
If instead, you want to check whether an email address is real, I'm afraid it isn't possible. There isn't a database of all existing email addresses.
The whole notion of whether an e-mail address "exists" is somewhat ambiguous. Does an auto-responder address "exist"? Does an address which can receive mail that is immediately discarded "exist"? Some mail servers can be effectively probed by initiating a mail delivery session and seeing if the mail server rejects the address as illegitimate. More savvy mail servers may quietly accept and discarded mail destined for "bogus" addresses to prevent address validation (i.e. to keep spammers from getting "good" addresses). What you're asking is non-trivial, and there's not really a clear cut answer.
There's no real way to confirm an email really exist other than sending it an email and seeing if you get a bounce-back (And even then some domains have catch-all's configured so it may not actually be an email).
You can validate the format of it to make sure it looks vaguely like an email. To truly validate an email takes an ungodly complex regex (I've yet to see one that truly encompasses the scope), but a simple check that'll rule out most keyboard-mashing is pretty easy. I typically use:
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$
There's a lot of fake emails it will accept, but it does a reasonable job of forcing the user to enter something legitimate. Be wary if using a more complex regex that you don't accidentally ban any legitimate addresses, the email spec is very broad in what's allowed.
You could also try doing a DNS lookup on the host portion of the email (After the @) for an extra level of protection, but I'm not sure how much you'll get from this as you'll just force them to lie with a real domain name.
精彩评论