SlideShare a Scribd company logo
6
Most read
7
Most read
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.
Validate Email with JavaScript.pdf
Validate Email with JavaScript.pdf
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

PPTX
Javascript
DOCX
translation document source for letsextract contacts
DOCX
Send email
DOC
Handout7 html forms
PPTX
Working with data.pptx
PPTX
Action Mailer
 
PDF
logincode carasen12
PDF
full stack practical assignment msc cs.pdf
Javascript
translation document source for letsextract contacts
Send email
Handout7 html forms
Working with data.pptx
Action Mailer
 
logincode carasen12
full stack practical assignment msc cs.pdf

Similar to Validate Email with JavaScript.pdf (20)

PPTX
GCSECS-DefensiveDesign.pptx
 
PDF
Working Software 2019 - TypeScript come (forse) non lo hai mai visto
PPTX
week 3 slides.pptx
PPTX
LAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email Infrastructure
PPTX
Web programming
PDF
KLab 2019 Meetup - TypeScript come (forse) non lo hai mai visto
PPT
Internal DSLs For Automated Functional Testing
PDF
33 "Must-Do" Tips to Improve HTML Email Design
PPTX
PHP Form Validation Technique
DOCX
Php forms and validations by naveen kumar veligeti
PDF
Hide email address in sourc...
PPTX
Java script ppt from students in internet technology
PDF
Email building best practice - a guide for designers
PPTX
Tips & tricks to render your email correctly on all devices
ODP
Action Mailer In Action
ODP
How To Build A Bulk Email Sending Application In PHP
PPTX
javascript.pptx
PPTX
Mobile Application Development (Sending emails)
PPT
Email Marketing
PPT
Scripting languages
GCSECS-DefensiveDesign.pptx
 
Working Software 2019 - TypeScript come (forse) non lo hai mai visto
week 3 slides.pptx
LAPHP/LAMPSig Talk: Intro to SendGrid - Building a Scalable Email Infrastructure
Web programming
KLab 2019 Meetup - TypeScript come (forse) non lo hai mai visto
Internal DSLs For Automated Functional Testing
33 "Must-Do" Tips to Improve HTML Email Design
PHP Form Validation Technique
Php forms and validations by naveen kumar veligeti
Hide email address in sourc...
Java script ppt from students in internet technology
Email building best practice - a guide for designers
Tips & tricks to render your email correctly on all devices
Action Mailer In Action
How To Build A Bulk Email Sending Application In PHP
javascript.pptx
Mobile Application Development (Sending emails)
Email Marketing
Scripting languages
Ad

Recently uploaded (20)

PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Cost to Outsource Software Development in 2025
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
17 Powerful Integrations Your Next-Gen MLM Software Needs
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Nekopoi APK 2025 free lastest update
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Cost to Outsource Software Development in 2025
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Complete Guide to Website Development in Malaysia for SMEs
wealthsignaloriginal-com-DS-text-... (1).pdf
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
17 Powerful Integrations Your Next-Gen MLM Software Needs
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Navsoft: AI-Powered Business Solutions & Custom Software Development
Digital Systems & Binary Numbers (comprehensive )
Advanced SystemCare Ultimate Crack + Portable (2025)
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Design an Analysis of Algorithms I-SECS-1021-03
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Designing Intelligence for the Shop Floor.pdf
CHAPTER 2 - PM Management and IT Context
Nekopoi APK 2025 free lastest update
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Ad

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.
  • 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.