Email validation. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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.

18th Jul 2016, 3:21 PM
Ack-Angel
Ack-Angel - avatar
9 Answers
+ 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
9th Aug 2016, 9:38 AM
Pedro Costa
Pedro Costa - avatar
+ 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\"[email protected]\". -----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..
23rd Aug 2016, 10:50 AM
fjlj
+ 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 ([email protected]) 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
24th Jul 2016, 9:35 AM
Dr.Na'el Hariri
Dr.Na'el Hariri - avatar
+ 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 )
8th Aug 2016, 4:06 AM
Pedro Costa
Pedro Costa - avatar
+ 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
8th Aug 2016, 5:48 AM
Ack-Angel
Ack-Angel - avatar
+ 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 )
8th Aug 2016, 5:59 AM
Pedro Costa
Pedro Costa - avatar
+ 1
okay thanks @pedro I would really appreciate the Link
8th Aug 2016, 6:31 AM
Ack-Angel
Ack-Angel - avatar
0
thanks that was helpful
9th Aug 2016, 10:33 AM
Ack-Angel
Ack-Angel - avatar
0
email validation is good for using email as input type
23rd Nov 2016, 4:41 PM
Sudip Singh
Sudip Singh - avatar