How to validate an email address in JavaScript
Loading
How to validate an email address in JavaScript
Hi,
We can validate the email address using regex in JavaScript.
function ValidateEmail(inputText){var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;if(inputText.value.match(mailformat)){return true;}else{return false;}}
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