JSFiddle - React, Tailwind, and code Playground

Using an email input in memory to validate an email address.

by Travis Almand

JavaScript

var $email = document.createElement('input');

$email.type = 'email';

// true
$email.value = '';
console.log('empty : ' + $email.validity.valid);

// false
$email.value = 'test';
console.log('test : ' + $email.validity.valid);

// true
$email.value = 'test@test';
console.log('test@test : ' + $email.validity.valid);

// true
$email.value = '[email protected]';
console.log('[email protected] : ' + $email.validity.valid);