Asp.net mask credit card number in text box as being entered followed by validation and processing of credit card number

StackOverflow https://stackoverflow.com/questions/15709807

Question

I am supporting an Asp.Net web applications which accepts and processes credit card. But due to new rules, I need to mask the credit card number as it's being entered. So if the first number is 4, it is visible until the next number is entered (e.g. 9), then the text box shows *9.

One way I could think of was to use JavaScript and hidden field to mask the credit card number on key up event and stored the CC in the hidden field. But I'm not sure if there is a better way of doing it. And also how to handle if user updates an existing number.

Are there any best practices for doing this? keep in mind I need those numbers and run validations before the credit card is processed and then process the credit card and store it in the database. I already have CC field in database encrypted.

Any suggestions/help would be highly appreciated.

Was it helpful?

Solution

There is a jQuery plugin that will do this for you:

http://blog.decaf.de/2009/07/iphone-like-password-fields-using-jquery/

OTHER TIPS

That's pretty much the only way you can do it. As for updating, you should never display the credit card number, so they will have to re-type their entire credit card number.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top