Bank account number is unique number with in organization to track a particular personal detail that’s sensitive information and should be masked so that unauthorized persons will not misuse it.
Most of the banks have unique account numbers, varies from 9 digits to 18 digits. Most of the banks (67 out of 78) have included branch code as part of the account number structure.
For branch code, In India use different terms as IFSC code and in USA use as routing number.
In USA, combination of account number and routing number together is very sensitive if a person know about both account number and routing number can transfer someone’s complete checking account money.
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
Account Number masking Example:
Here considering, account number of length 10 digits. By masking will hide initial 6 digits and show only last 4 digits. For example, my account number is 1234567890 than after mask will display as XXXXXX7890.
![]() |
![]() |
HTML Changes
Create a text box on your page with below html.
<b>Account Number:</b>
Java Script/JQuery Changes
Copy below java script in your head section of page.
var originalVal; $(document).ready(function() { if($('#txtAC').val().length>0) { if($('#txtAC').val().indexOf("X")==-1) { originalVal=$('#txtAC').val(); } maskAccountNumber(this); } $('#txtAC').blur( function(e) { if($('#txtAC').val().indexOf("X")==-1) { originalVal=$('#txtAC').val(); } maskAccountNumber(this); }); $('#txtAC').focus( function(e) { $(this).val(originalVal); }); }); function maskAccountNumber(regularAC) { var varlen =$(regularAC).val().length; if(varlen > 10) { $("#error").text('Not Valid Accont Number.'); } else { $("#error").text(''); var str = $(regularAC).val(); var mask = varlen > 0 ? varlen > 1 ? varlen > 2 ? varlen > 3 ? varlen > 4 ? varlen > 5 ? 'XXXXXX'+ str.substring(6) : 'XXXXX' : 'XXXX' : 'XXX' : 'XX' : 'X' : ''; $(regularAC).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.
Drop me your questions in comments section.
References