Sample JavaScript for Email Validation

Sample JavaScript for Email Validation

Sample JavaScript:

let strEmail = 'test@test';
let strEmailRegEx = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
console.log(
	'Is Email ' + strEmail + ' valid?',
	strEmailRegEx.test(
		strEmail
	)
);
strEmail = '[email protected]';
console.log(
	'Is Email ' + strEmail + ' valid?',
	strEmailRegEx.test(
		strEmail
	)
);

Leave a Reply