Javascript example: validate email using regex

Example validating email using regex in Javascript

This example defines a validateEmail function that checks an email address against a regular expression with .test(). It walks through valid and invalid sample addresses so you can see how anchors, allowed characters, the @ sign, domain text, and top-level domain length affect validation.

Result

Console output