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


