Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Javascript Email Mask
Create a Mask in an email address
This function create a mask using a valid email address.
This is usefull when someone need to confirm the email used in a system
Author: Gabriel Froes -
function emailMask(email) {
var maskedEmail = email.replace(/([^@\.])/g, "*").split('');
var previous = "";
if (i<=1 || previous == "." || previous == "@"){
maskedEmail[i] = email[i];
previous = email[i];
return maskedEmail.join('');
// Usage:
// console.log ( emailMask("") );
// Output: my.e****@m*******.c**

This comment has been minimized.

Copy link

commented Jan 16, 2019

excellent code 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.