0
Email validation.
Can someone give me a hint on how to write a .js script to check emails on a login page whether it is correct by searching Google or the email provider of the person and return back to the script if valid or not.
9 ответов
+ 2
See if you can deal with this :
https://www.npmjs.com/package/email-existence
it does what i said earlier . It pings and gets a reaponse
+ 2
The best you could do with just js is test the string for a "valid" email format.. Better of basing it by most common username standards as emails can technically be almost anything..
As
"(Trused email)admin\".@microsoft.com\". -----verified+safe"@[137.235.12.32]
Is technically a valid email address...
So we would look for some of the industry standards..
Has somevalid characters then an @ then some valid characters followed by a domain extension..
The following regular expression matches.
At least one or more a-z,0-9,-,+,=,. In any case.. (A single symbol likely would jot be valid without quotes.. But a single char would.. For simplicity we are saying eh we allow all of these chars but no others and we want atleast 1)
An @ symbol
A string that matches domain rules od LDH (letters,digits,hyphens) in any case
A dot.
And a string that is atleast 1 character long and a-z in any case.
var pattern = /[(a-z|0-9|\-\+\=\.)]+@[(a-z|0-9|\-)]+\.[a-z]+/i;
var valid_email = pattern.test(email_input);
If the email matches the regular expression it will set valid_email to true.
This is a quick regex.. We could get a lot more involved.. But for general email format validation based on "username" rules of most common email suppliers.. This will do the trick..
+ 1
you can't do that with JavaScript alone (as it's a client-side language. unless you combine it with node.js, AJAX or PHP
with JavaScript alone, you can check that it's a valid email (someone@company.stuff)
practically, it's not enough to check of such an email exists. you need to check if this is really THEIR email, which can't be done without a confirmation email
+ 1
Adding some more stuff on what sir Na'el said, you can check if it has the "@" symbol somewhere or check if it ends in .com, etc... ( html5 has an email verification, you could check it out for client-side )
+ 1
thats right but there is a simple method of checking if the email ends with .com or @example.com which is by changing the input type from text - email...but havent got the clue of making a script to actually check if the email entered do exist or not cos someone can easily input any email in the page
+ 1
To verify if a mail exists you can ping it, like you. can ping a website . Through MX ( blablabla you might Not understand. ) To keep it simple, check out for a framework (like node.JS) or an api
if I'm not being conclusive, I'll drop here later some links to help you ( when I get home )
+ 1
okay thanks @pedro I would really appreciate the Link
0
thanks that was helpful
0
email validation is good for using email as input type