credit card mask js

JavaScript
function maskify(cc) {
  return cc.replace(/.(?=.{4})/g, "#");
}
Source

Also in JavaScript: