I am currently maintaining an Asp.Net web application that deals with processing credit card payments. However, in order to comply with new regulations, I am required to mask the credit card number as it is being entered. For example, if the first number entered is 4
, it should be visible until the next number (e.g. 9) is inputted, then the text box should display *9
.
One solution I have considered is utilizing JavaScript and a hidden field to mask the credit card number on key up event and store the unmasked number in the hidden field. Nevertheless, I am open to exploring better alternatives. Additionally, I need guidance on handling scenarios where a user modifies an existing digit.
Are there any recommended practices for implementing this functionality? It is crucial that I retain access to the numbers for validation purposes before the payment is processed, at which point the credit card information will be stored securely in the database. The credit card details are already stored encrypted in the database.
Any advice or suggestions on how to achieve this would be greatly valued.