JavaScript email validation


Although front end validation is not an only form of validation you should do, you’d still want to validate forms on front end. As forms usually have email address of the person filling it in, it could be useful to do JavaScript email validation. Therefore, I have just focused on single JavaScript method. You will find a method that will validate your email value. You need to provide a string value to the method so it would output if email is valid or not.

function validEmail(email) {
	var filter = /^([w-]+(?:.[w-]+)*)@((?:[w-]+.)*w[w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$/i
	if(!filter.test(email)) {
		return true;
	} else {
		return false;