Jump to content
  • 0

Mask the account number except for the last four digits


cordova

Question

4 answers to this question

Recommended Posts

  • 0

You can technically do this by concatenating a set of asterisks next to the last four digits of the account number, like so:

"******" + right([@field:Account_Number], 4)


But you can also achieve this using:

replicate('*',len([@field:Account_Number])-4) + right([@field:Account_Number], 4)

You can use this so that you won't have to worry if the asterisks add up to the actual preceding characters, because this basically turns all characters before the last x digits into asterisks.

Link to comment
Share on other sites

  • 0

Just to add, you may also consider this workaround:

If you want to show the value in report page, add HTML Block and use the code below in source:

<div id="sn[@field:Id]"></div>

<script>

var ssn = '[@field:CCField]';

document.getElementById('sn[@field:Id]').innerHTML= "*****" + ssn.substr(ssn.length - 4);

</script>

"[@field:Id]" needs to be replaced with the field which is holding unique identifier and [@field:Field] with appropriate field.

Also, if you want to show the value in details page then you can add a virtual field (here we have Virtual1) and use the code below to the footer:

<script>

var ssn = '[@field:CCField]';

document.getElementById('cbParamVirtual1').value= "*****" + ssn.substr(ssn.length - 4);

</script>

Moreover, if you want this field to be editable you can add a Virtual Checkbox , update CC, and set a Rule to hide Virtual 1 if Virtual 2 is checked and hide CCField if Virtual2 is not checked. This way you can see the whole value and update.

And you may also use the code below for Single Record Update DataPage and put the code inside the footer:

<script>

var ssn = document.getElementById('EditRecordCCNumber');

 

ssn.value = new Array(ssn.value.length-3).join('x') +

ssn.value.substr(ssn.value.length-4, 4);

 

</script>

 The last four number of the credit card will only be shown and numbers before it will be masks after you click the update button (this is using Single Record Update DataPage):

image.png.3e955aafb49fb33332c6dcb5eeed0cbd.png

Link to comment
Share on other sites

  • 0

Hi! If you would like to automatically format SSN/Social Security Number in the Text Field, you can try these solutions:

1. From this link: https://stackoverflow.com/questions/7685175/autoformat-ssn-while-entering-the-number#:~:text=at 0%3A25-,Karl Keefer,-6361 - JavaScript

Applying in the DataPage's Footer with this code:

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {

function formatSSN(ssn) {

  // remove all non-dash and non-numerals
  var val = ssn.replace(/[^\d-]/g, '');

  // add the first dash if number from the second group appear
  val = val.replace(/^(\d{3})-?(\d{1,2})/, '$1-$2');

  // add the second dash if numbers from the third group appear
  val = val.replace(/^(\d{3})-?(\d{2})-?(\d{1,4})/, '$1-$2-$3');

  // remove misplaced dashes
  val = val.split('').filter((val, idx) => {
    return val !== '-' || idx === 3 || idx === 6;
  }).join('');

  // enforce max length
  return val.substring(0, 11);

}

// bind our function
document.getElementById("InsertRecordSSN").onkeyup = function(e) {
  this.value = formatSSN(this.value);

}

});

</script>

2. https://stackoverflow.com/questions/7685175/autoformat-ssn-while-entering-the-number#:~:text=at 6%3A20-,Jason Hansen,-33 - jQuery
 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {

 $('#InsertRecordSSN').keyup(function() {
          var val = this.value.replace(/\D/g, '');
          var newVal = '';
          if(val.length > 4) {
             this.value = val;
          }
          if((val.length > 3) && (val.length < 6)) {
             newVal += val.substr(0, 3) + '-';
             val = val.substr(3);
          }
          if (val.length > 5) {
             newVal += val.substr(0, 3) + '-';
             newVal += val.substr(3, 2) + '-';
             val = val.substr(5);
           }
           newVal += val;
           this.value = newVal.substring(0, 11);
        });

});

</script>

3. By using Cleave JS - https://nosir.github.io/cleave.js/

<script src="https://cdnjs.cloudflare.com/ajax/libs/cleave.js/1.6.0/cleave.min.js"></script>

<script>

var cleave = new Cleave('#InsertRecordSSN', {
    delimiter: '-',
    blocks: [3,2,4],
    numericOnly: true
});

</script>

Take note that you need to change the InsertRecordSSN based on your right field name. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...