Hide the Email Id in a form using HTML and JavaScript
Here the following task is going to be formed with HTML code:
1.Input field: We are going to enter the email id in this field.
2.Button: On clicking this button hidden email id will be displayed.
3.Output field: Field to display hidden email id.
Examples:
Input :robin_singh@gmail.com Output :robin*****@gmail.com Input :geeksforgeeks@gmail.com Output :geeks*****@gmail.com
HTML code :
<!DOCTYPE html> <html> <head> <title></title> <script type="text/javascript"> function test_str(){ var str = document.getElementById("t1").value ; var idx = str.indexOf('@'); var res = str.replace(str.slice(5, idx), "*".repeat(5)); document.getElementById("t2").value = res; } </script> </head> <body> <p> Email: <input type="text" placeholder="abc" id="t1"/><br/> <input type="button" value="Protect" onclick="test_str()"/><br/> Output: <input type="text" id="t2" readonly/> </p> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- HTML | DOM Input Email form Property
- Form validation using HTML and JavaScript
- Hide or show elements in HTML using display property
- Email Template using HTML and CSS
- HTML | DOM Input Email value Property
- HTML | DOM Input Email Object
- HTML | DOM Input Email name Property
- HTML | <input type="email">
- HTML | DOM Input Email disabled Property
- HTML | DOM Input Email defaultValue Property
- HTML | DOM Input Email readOnly Property
- HTML | DOM Input Email maxLength Property
- HTML | DOM Input Email pattern Property
- HTML | DOM Input Email multiple Property
- HTML | DOM Input Email Placeholder Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



