Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen Roscam 13 posts 113 karma points
    Feb 18, 2019 @ 07:51
    Jeroen Roscam
    0

    Razor email-template: show only last digits of account numer

    Hello everyone,

    In the email Example-Template.cstml in \Views\Partials\Forms\Emails, I am trying to show only the last 4 digits of an account number, and mask the rest with * or x.

    I found several javascript options online, but I didn't manage to get them to work with Razor. In most cases, the email wasn't sent at all. I have to admit my knowledge of both Razor and javascript is basic at best.

    But I can't imagine I'm the first who tries to do this. Does anyone have a solution?

    Best, Jeroen

  • louisjrdev 107 posts 344 karma points c-trib
    Feb 18, 2019 @ 10:35
    louisjrdev
    100

    Hi,

    You might want something like this:

    @{
        var accountNumberRedacted = "**** **** **** " + accountNumber.Substring(Math.Max(0, accountNumber.Length - 4)); 
    }
    

    So if your account number is

    1234 5678 9101 1121

    you would get **** **** **** 1121

  • Jeroen Roscam 13 posts 113 karma points
    Feb 18, 2019 @ 10:49
    Jeroen Roscam
    0

    Thank you, that worked great! (Could have saved myself a week of trying by posting on here immediately).

    Thanks, Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft