Jump to content

Mask credit card information in text box


jebaraj

Recommended Posts

If you're looking to hide the number after it's been entered and submitted, you could use something like this:

 

<?php
$ccNum = "2222 1111 3333 4444";
print "<div>$ccNum</div>";
$ccNum_lastFour = substr($ccNum, -4);
$ccNum = preg_replace("~\d~", '*', $ccNum);
$ccNum = substr($ccNum, 0, -4) . $ccNum_lastFour;
print "<div>$ccNum</div>";
?>

 

 

If you're looking to hide the credit card as it's being typed into the form, you'll need to look into solution using a client-side option like JavaScript.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.