
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to hide e-mail address from an unauthorized user in JavaScript?
Hiding an e-mail address
The following steps are to be followed to hide our e-mail from unauthorized users.
- In every email address '@' symbol is common so try to remove it from the email address using split() method. In the following example after splitting the email(batman@gmail.com) we get the result as batman, gmail.com.
- Divide the result in to 2 parts(split1 and split2).
- Using substring() method remove some of string from split1 and join resulted part with split2 using '...@'.
- Return the joined part as the final output. In our example the resulted output is "bat...@gmail.com".
Example
<html> <body> <script type="text/javascript"> newEmail = function (email) { var split = email.split("@"); var split1 = split[0]; var avg = split1.length / 2; split1 = split1.substring(0, (split1.length - avg)); split2 = split[1]; return split1 + "...@" + split2; }; document.write(newEmail("batman@gmail.com")); </script> </body> </html>
output
bat...@gmail.com
- Related Articles
- How should I validate an e-mail address in Android?
- How should I validate an e-mail address in Android using Kotlin?.
- How to hide an IP address
- How to get the Android device's primary e-mail address?
- What is an Electronic Mail (E-Mail)?
- Sending an HTML e-mail using Python
- Sending Attachments as an E-mail using Python
- How to use JavaScript to hide a DIV when the user clicks outside of it?
- How can I send mail from an iPhone application?
- Explain the E-Mail Format in Computer Network.
- Determining the User IP Address in Node
- How MySQL prevents unauthorized clients from accessing the database system?
- How to validate URL address in JavaScript?
- How to validate email address in JavaScript?
- How to hide _id from Aggregation?

Advertisements