Rajanikant Hawaldar
How to validate an email address in JavaScript

How to validate an email address in JavaScript

By Rajanikant Hawaldar in JavaScript on Oct 10 2020
  • Ganesan C
    Aug, 2021 16

    Hi,
    We can validate the email address using regex in JavaScript.

    1. function ValidateEmail(inputText)
    2. {
    3. var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
    4. if(inputText.value.match(mailformat))
    5. {
    6. return true;
    7. }
    8. else
    9. {
    10. return false;
    11. }
    12. }

    • 1
  • Ranjit kumar
    Oct, 2020 27

    Email Validation in JavaScript – Step by Step
    Validating email is a very important point while validating an HTML form. An email is a string or a subset of ASCII characters that are separated into two parts by “@” symbol.

    The first part can consist of the following ASCII Characters:

    Uppercase (A-Z) and lowercase (a-z) letters
    Digits (0-9)
    Characters such as ! # $ % & ‘ * + – / = ? ^ _ ` { | } ~
    Character . ( period, dot or fullstop) but it should not be the first or last character and should not come one after the other

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS