{"id":4705,"date":"2019-05-23T10:38:24","date_gmt":"2019-05-23T05:08:24","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=4705"},"modified":"2019-05-23T16:31:29","modified_gmt":"2019-05-23T11:01:29","slug":"how-to-validate-email-id-in-javascript","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-validate-email-id-in-javascript\/","title":{"rendered":"HOW TO VALIDATE  EMAIL ID IN JAVASCRIPT."},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">HOW TO VALIDATE&nbsp; EMAIL ID IN JAVASCRIPT.<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Date : 23\/05\/2019<\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">INTRODUCTION:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"> In this article, to clarify how to validate email id in javascript, so that we are going to use the <strong>sane-email-validation.<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/encrypted-tbn0.gstatic.com\/images?q=tbn:ANd9GcSnau6ZnK5ffYvKDlST2FvbTK78_TImN36G2VDoQuFeVEXIhOgM\" alt=\"Related image\" width=\"335\" height=\"227\"\/><figcaption>Validation<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">VALIDATE USING isEmail():<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"> On the other hand, using Email() function in javascript will check your email id is valid or not.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example,&nbsp;the code is given below,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">var isEmail = require( \"sane-email-validation\" ); \/\/ require the installed packagersane-email-validator)\nvar email = \"yyyyygmail.com\";  \/\/ store input to the variable\n \nif ( isEmail( email ) ) {. \/\/validate email using isEmail function\n    console.log( email + \" is valid. \" );  \n} else {\n    console.log( email + \" is not valid. \" );\n}\n\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Moreover, the result is attached below.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<ul class=\"wp-block-gallery columns-1 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\"><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"474\" height=\"31\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/email1.png\" alt=\"\" data-id=\"4710\" data-link=\"https:\/\/pheonixsolutions.com\/blog\/?attachment_id=4710\" class=\"wp-image-4710\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/email1.png 474w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/email1-300x20.png 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/figure><\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">VALIDATE USING isNotEmail():<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Most importantly,&nbsp; using<strong> isNotEmail() function<\/strong> in javascript will check your email id is valid or not. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For instance, the sample code is<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">var\u00a0isNotEmail\u00a0=\u00a0require(\u00a0\"sane-email-validation\"\u00a0).isNotEmail;\nvar email = \"aaaa@gmail.com\"; \nif\u00a0(\u00a0isNotEmail(\u00a0email\u00a0)\u00a0)\u00a0{\n\u00a0\u00a0console.log(\u00a0email\u00a0+\u00a0\"\u00a0is\u00a0not\u00a0valid.\"\u00a0);\n}\u00a0else\u00a0{\n\u00a0\u00a0console.log(\u00a0email\u00a0+\u00a0\"\u00a0is\u00a0valid.\"\u00a0);\n}\n\n<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">OUTPUT:<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Meanwhile, the snapshot for output.<\/p>\n\n\n\n<ul class=\"wp-block-gallery columns-1 is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\"><li class=\"blocks-gallery-item\"><figure><img decoding=\"async\" width=\"673\" height=\"31\" src=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/EMAIL.png\" alt=\"\" data-id=\"4719\" data-link=\"https:\/\/pheonixsolutions.com\/blog\/?attachment_id=4719\" class=\"wp-image-4719\" srcset=\"https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/EMAIL.png 673w, https:\/\/pheonixsolutions.com\/blog\/wp-content\/uploads\/2019\/05\/EMAIL-300x14.png 300w\" sizes=\"(max-width: 673px) 100vw, 673px\" \/><\/figure><\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for using&nbsp;<a href=\"https:\/\/pheonixsolutions.com\/\">pheonix solutions<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You find this tutorial helpful? Share with your friends to keep it alive.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>HOW TO VALIDATE&nbsp; EMAIL ID IN JAVASCRIPT. Date : 23\/05\/2019 INTRODUCTION: In this article, to clarify how to validate email [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[660,661,337],"class_list":["post-4705","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-emailid-validation","tag-javascript","tag-nodejs","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1dT","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4705","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=4705"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/4705\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=4705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=4705"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=4705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}