SlideShare a Scribd company logo
1 of 11
Download to read offline
Validate Email with JavaScript
Validate an Email address is very important.
This validation can be performed in many
computer languages but today we are going
to Validate Email with JavaScript.
What is JavaScript ?
Javascript is a scripting computer language
and its abbreviation is JS. It is used to
develop complex web applications However
it is always used with CSS and HTML. It is
different from the Java computer language.
Why Validate Email Address
In today’s world, most of the important
communication is done through Email
addresses. Collecting email addresses is not
only important but it becomes essential
when it comes to Email Marketing.
Therefore validating the email address
Structure of Email Address
Consider this email address as a sample
ContactUs@EmailConcern.com. It is a valid email address. Now it
consists of 3 parts
Before @ :: It consists of the name of the email address. This part
consists of letters (capital as well as small), numbers, and special
characters.
After @ :: It consists of a domain name so here you can use (capital as
well as small), numbers, and special characters.
After dot :: It defines the type of the domain like com, org, etc. In this
part, only letters (capital as well as small), numbers, and dot(optional)
can appear.
Validate Email with JavaScript
To validate the Email with Javascript I use the following code.
<!DOCTYPE html>
<html>
<body>
<h1>Validate Email with JavaScript</h1>
<input id="EmailAddress">
<button type="button" onclick="VALIDATE_EMAIL_ADDRESS()">Submit</button>
<h2 id="Result" style="color: Green;"></h2>
<script>
function VALIDATE_EMAIL_ADDRESS() {
var email;
email = document.getElementById("EmailAddress").value;
var reg = /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-z]{2,4})$/;
Validate Email with JavaScript
if (reg.test(EmailAddress.value) == false)
{
document.getElementById("Result").style.color = "red";
document.getElementById("Result").innerHTML ="Invalid EMail Address "+ email;
return false;
}
else
{
document.getElementById("Result").style.color = "Green";
document.getElementById("Result").innerHTML ="Valid Email Address"+email;
}
return true;
}
</script>
To test the above mention code I used
W3School JavaScript online editor. In this
editor just paste the code into the editor and
press the Run button.
Conclusion
In order to collect valid email addresses, this
validation is mandatory. You cannot skip this
step. It not only makes things easy for you but
also ensures data integrity.

More Related Content

Similar to Validate Email with JavaScript.pdf

Working Software 2019 - TypeScript come (forse) non lo hai mai visto
Working Software 2019 - TypeScript come (forse) non lo hai mai vistoWorking Software 2019 - TypeScript come (forse) non lo hai mai visto
Working Software 2019 - TypeScript come (forse) non lo hai mai vistoGianluca Carucci
 
LAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email Infrastructure
LAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email InfrastructureLAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email Infrastructure
LAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email InfrastructureSendGrid
 
KLab 2019 Meetup - TypeScript come (forse) non lo hai mai visto
KLab 2019 Meetup - TypeScript come (forse) non lo hai mai vistoKLab 2019 Meetup - TypeScript come (forse) non lo hai mai visto
KLab 2019 Meetup - TypeScript come (forse) non lo hai mai vistoGianluca Carucci
 
Internal DSLs For Automated Functional Testing
Internal DSLs For Automated Functional TestingInternal DSLs For Automated Functional Testing
Internal DSLs For Automated Functional TestingJohn Sonmez
 
33 "Must-Do" Tips to Improve HTML Email Design
33 "Must-Do" Tips to Improve HTML Email Design33 "Must-Do" Tips to Improve HTML Email Design
33 "Must-Do" Tips to Improve HTML Email DesignPinpointe On-Demand
 
PHP Form Validation Technique
PHP Form Validation TechniquePHP Form Validation Technique
PHP Form Validation TechniqueMorshedul Arefin
 
Php forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiPhp forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiNaveen Kumar Veligeti
 
Hide email address in sourc...
Hide email address in sourc...Hide email address in sourc...
Hide email address in sourc...chaitanya535
 
Email building best practice - a guide for designers
Email building best practice - a guide for designersEmail building best practice - a guide for designers
Email building best practice - a guide for designersVRAMP Employee Engagement
 
Tips & tricks to render your email correctly on all devices
Tips & tricks to render your email correctly on all devicesTips & tricks to render your email correctly on all devices
Tips & tricks to render your email correctly on all devicesCopernica BV
 
Action Mailer In Action
Action Mailer In ActionAction Mailer In Action
Action Mailer In ActionRob Kaufman
 
How To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPHow To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPSudheer Satyanarayana
 
javascript.pptx
javascript.pptxjavascript.pptx
javascript.pptxhasiny2
 
Scripting languages
Scripting languagesScripting languages
Scripting languagesteach4uin
 
Pranavi verma-class-9-email-messaging
Pranavi verma-class-9-email-messagingPranavi verma-class-9-email-messaging
Pranavi verma-class-9-email-messagingPranaviVerma
 
Pranavi verma-it 402 class ix-unit 11_presentation
Pranavi verma-it 402 class ix-unit 11_presentationPranavi verma-it 402 class ix-unit 11_presentation
Pranavi verma-it 402 class ix-unit 11_presentationPranaviVerma
 

Similar to Validate Email with JavaScript.pdf (20)

Working Software 2019 - TypeScript come (forse) non lo hai mai visto
Working Software 2019 - TypeScript come (forse) non lo hai mai vistoWorking Software 2019 - TypeScript come (forse) non lo hai mai visto
Working Software 2019 - TypeScript come (forse) non lo hai mai visto
 
week 3 slides.pptx
week 3 slides.pptxweek 3 slides.pptx
week 3 slides.pptx
 
LAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email Infrastructure
LAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email InfrastructureLAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email Infrastructure
LAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email Infrastructure
 
Web programming
Web programmingWeb programming
Web programming
 
KLab 2019 Meetup - TypeScript come (forse) non lo hai mai visto
KLab 2019 Meetup - TypeScript come (forse) non lo hai mai vistoKLab 2019 Meetup - TypeScript come (forse) non lo hai mai visto
KLab 2019 Meetup - TypeScript come (forse) non lo hai mai visto
 
Internal DSLs For Automated Functional Testing
Internal DSLs For Automated Functional TestingInternal DSLs For Automated Functional Testing
Internal DSLs For Automated Functional Testing
 
33 "Must-Do" Tips to Improve HTML Email Design
33 "Must-Do" Tips to Improve HTML Email Design33 "Must-Do" Tips to Improve HTML Email Design
33 "Must-Do" Tips to Improve HTML Email Design
 
PHP Form Validation Technique
PHP Form Validation TechniquePHP Form Validation Technique
PHP Form Validation Technique
 
Php forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligetiPhp forms and validations by naveen kumar veligeti
Php forms and validations by naveen kumar veligeti
 
Hide email address in sourc...
Hide email address in sourc...Hide email address in sourc...
Hide email address in sourc...
 
Email building best practice - a guide for designers
Email building best practice - a guide for designersEmail building best practice - a guide for designers
Email building best practice - a guide for designers
 
Tips & tricks to render your email correctly on all devices
Tips & tricks to render your email correctly on all devicesTips & tricks to render your email correctly on all devices
Tips & tricks to render your email correctly on all devices
 
Action Mailer In Action
Action Mailer In ActionAction Mailer In Action
Action Mailer In Action
 
How To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPHow To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHP
 
javascript.pptx
javascript.pptxjavascript.pptx
javascript.pptx
 
Email Marketing
Email MarketingEmail Marketing
Email Marketing
 
Scripting languages
Scripting languagesScripting languages
Scripting languages
 
forms.pptx
forms.pptxforms.pptx
forms.pptx
 
Pranavi verma-class-9-email-messaging
Pranavi verma-class-9-email-messagingPranavi verma-class-9-email-messaging
Pranavi verma-class-9-email-messaging
 
Pranavi verma-it 402 class ix-unit 11_presentation
Pranavi verma-it 402 class ix-unit 11_presentationPranavi verma-it 402 class ix-unit 11_presentation
Pranavi verma-it 402 class ix-unit 11_presentation
 

Recently uploaded

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Recently uploaded (20)

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 

Validate Email with JavaScript.pdf

  • 1. Validate Email with JavaScript
  • 2. Validate an Email address is very important. This validation can be performed in many computer languages but today we are going to Validate Email with JavaScript.
  • 3. What is JavaScript ? Javascript is a scripting computer language and its abbreviation is JS. It is used to develop complex web applications However it is always used with CSS and HTML. It is different from the Java computer language.
  • 4. Why Validate Email Address In today’s world, most of the important communication is done through Email addresses. Collecting email addresses is not only important but it becomes essential when it comes to Email Marketing. Therefore validating the email address
  • 5. Structure of Email Address Consider this email address as a sample ContactUs@EmailConcern.com. It is a valid email address. Now it consists of 3 parts Before @ :: It consists of the name of the email address. This part consists of letters (capital as well as small), numbers, and special characters. After @ :: It consists of a domain name so here you can use (capital as well as small), numbers, and special characters. After dot :: It defines the type of the domain like com, org, etc. In this part, only letters (capital as well as small), numbers, and dot(optional) can appear.
  • 6. Validate Email with JavaScript To validate the Email with Javascript I use the following code. <!DOCTYPE html> <html> <body> <h1>Validate Email with JavaScript</h1> <input id="EmailAddress"> <button type="button" onclick="VALIDATE_EMAIL_ADDRESS()">Submit</button> <h2 id="Result" style="color: Green;"></h2> <script> function VALIDATE_EMAIL_ADDRESS() { var email; email = document.getElementById("EmailAddress").value; var reg = /^([A-Za-z0-9_-.])+@([A-Za-z0-9_-.])+.([A-Za-z]{2,4})$/;
  • 7. Validate Email with JavaScript if (reg.test(EmailAddress.value) == false) { document.getElementById("Result").style.color = "red"; document.getElementById("Result").innerHTML ="Invalid EMail Address "+ email; return false; } else { document.getElementById("Result").style.color = "Green"; document.getElementById("Result").innerHTML ="Valid Email Address"+email; } return true; } </script>
  • 8. To test the above mention code I used W3School JavaScript online editor. In this editor just paste the code into the editor and press the Run button.
  • 9.
  • 10.
  • 11. Conclusion In order to collect valid email addresses, this validation is mandatory. You cannot skip this step. It not only makes things easy for you but also ensures data integrity.