[thelist] hide some numbers and show others script.

Chris Marsh chris at ecleanuk.com
Fri Jun 20 06:46:20 CDT 2003


Kristina

>   Morning folks!
> 
>   I'm looking for a script that will hide the first part of a
>   number and just display the last 4 digits.
> 
>   I have seen this in action on websites, where cc numbers are just
>   showing last 4 digits for confirmation and the beginning is *'s.
> 
>   Searching using google hasn't given me much, as I'm struggling to
>   define my search.

I assume you're doing this on the server. You don't say what technology
you're using, so I'll try VBScript (ASP).

Function HideNumber(sNumber)
	Dim iLength
	Dim sNewNumber
	Dim i
	sNumber = Replace(sNumber, " ", "")
	iLength = Len(sNumber)
	For i = 1 To (iLength - 4)
		sNewNumber = sNewNumber & "*"
	Next
	sNewNumber = sNewNumber & Mid(sNumber, iLength - 3)
	HideNumber = sNewNumber
End Function

>   Also how safe is this?

Should be fine on the server, I wouldn't recommend sending the credit
card number down the pipe and then manipulating it with JavaScript on
the client.

HTH

Regards

Chris Marsh



More information about the thelist mailing list