HOW TO VALIDATE EMAIL ID IN JAVASCRIPT.

HOW TO VALIDATE  EMAIL ID IN JAVASCRIPT.

Date : 23/05/2019

INTRODUCTION:

In this article, to clarify how to validate email id in javascript, so that we are going to use the sane-email-validation.

Related image
Validation

VALIDATE USING isEmail():

On the other hand, using Email() function in javascript will check your email id is valid or not.

For example, the code is given below,

var isEmail = require( "sane-email-validation" ); // require the installed packagersane-email-validator)
var email = "yyyyygmail.com";  // store input to the variable
 
if ( isEmail( email ) ) {. //validate email using isEmail function
    console.log( email + " is valid. " );  
} else {
    console.log( email + " is not valid. " );
}

Moreover, the result is attached below.

Output

VALIDATE USING isNotEmail():

Most importantly,  using isNotEmail() function in javascript will check your email id is valid or not.

For instance, the sample code is

var isNotEmail = require( "sane-email-validation" ).isNotEmail;
var email = "aaaa@gmail.com"; 
if ( isNotEmail( email ) ) {
  console.log( email + " is not valid." );
} else {
  console.log( email + " is valid." );
}

OUTPUT:

Meanwhile, the snapshot for output.

Thanks for using pheonix solutions.

You find this tutorial helpful? Share with your friends to keep it alive.

admin

Our team has expertise across software and web development, WordPress, e-commerce, mobile applications, UI/UX, cloud and infrastructure, DevOps, CI/CD, API integration, security, testing, automation, and technical support. The team also works with AI-based software solutions, LLMs, AI workflows, AI agents, and intelligent application development to help businesses automate processes and build smarter digital solutions. We focus on developing, deploying, maintaining, and optimising secure, scalable, and reliable technology solutions while helping businesses adopt modern technologies and drive digital transformation.

Leave a Reply

Scroll to Top