An Internet Protocol address (IP address) is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. An IP address serves two main functions: host or network interface identification and location addressing.
IP addresses are usually written and displayed in human-readable notations, such as 178.17.253.12 .
The reason to hide your IP address is simply for more privacy and to prevent misuse of your personal information. Whenever you access a website, the server you connect to logs your IP address and attaches it to all the other data the site can learn about you: your browsing habits, what you click on, how long you spend looking at a particular page. They then sell this data to advertising companies who use it to tailor ads straight to you. This is why ads on the internet sometimes feel oddly personal: it’s because they are. Your IP address can also be used to track your location, even when your location services are turned off.
See Also :
- Log4j2: How to Mask Logs Personal/Confidential/SPI Information
- How to Mask JSON Confidential/Personal Information in logs :JAVA
- How to mask JAVA Object confidential/personal information in logs while Printing
- How to MASK XML Confidential/Personal Data : JAVA
- How to mask Personal/Confidential Information on web page
IP (Internet Protocol) Masking Example
Here considering, IP address is represent as above. By masking will hide all digits except dot (.) . For example, IP address is 178.17.253.12 than after mask will display as XXX.XX.XXX.XX .
![]() | ![]() |
HTML Changes
Create a text box on your page as in attachment of download section.
Java Script/JQuery Changes
Copy below java script in your head section of page.
var originalVal;
$(document).ready(function()
{
if($('#txtIP').val().length>0)
{
if($('#txtIP').val().indexOf("X")==-1)
{
originalVal=$('#txtIP').val();
}
maskIP(this);
}
$('#txtIP').blur( function(e)
{
if($('#txtIP').val().indexOf("X")==-1)
{
originalVal=$('#txtIP').val();
}
maskIP(this);
});
$('#txtIP').focus( function(e)
{
$(this).val(originalVal);
});
});
function maskIP(regularIP)
{
var varlen =$(regularIP).val().length;
//to check only allow char as . and numbers
if($(regularIP).val().match(/[^.\d]/))
{
$("#error").text('Not Valid IP.');
}
else
{
$("#error").text('');
var str = $(regularIP).val();
//Replace all digits with X except .
var mask = $(regularIP).val().replace(/\d/gi, 'X');
$(regularIP).val(mask);
}
}
Note :
This masking example is created considering standard length of text size and formatting of text field, that can vary according to organizations. If your organization having different format and text size modify source code according to your need. If you are facing any issue drop a comments will try to connect as soon as possible.
Download Source code
To download the source code of this example, click on below given download link. Mask IP
References
Related Posts
Your Feedback Motivate Us
If our FacingIssuesOnIT Experts solutions guide you to resolve your issues and improve your knowledge. Please share your comments, like and subscribe to get notifications for our posts.
Happy Learning !!!
You must log in to post a comment.