Home > Net >  I must avoid entering letters on my digipas
I must avoid entering letters on my digipas

Time:10-26

I have a small problem. When I enter a new transfert of 269 euros with the account bank number BE072750044-35066. I have to introduce a code of confirmation. The code is 350269.

enter image description here

The figures 350 are the last 5 figures of the bank account number -> BE072750044-35066. And the 269 represents the amount for the new transfert.

Another example, if the new transfert was of 350 euros. We will have 350350.

enter image description here

Now my problem, if I have an account bank with a letter at the end. FR5940802053780006178110K61.

The problem is that I retrieve 10K269, but the user must enter only numbers on the digipas. How to avoid this problem for the user, please?

enter image description here

getTokenTwoAdd(nt) {
    var partOne, partTwo, absoluteAmount;
    partOne = (nt.iban.substr(nt.iban.length - 5)).substring(0, 3);
    absoluteAmount = Math.abs(nt.amount);
    absoluteAmount = parseInt(absoluteAmount);
    partTwo = ((absoluteAmount < 100) ? this.helpers.addLeadingZeroesLeft(absoluteAmount, 3) : absoluteAmount)   "";
    partTwo = partTwo.substring(0, 3);
    console.log("Iban number, slice => "   partOne);
    console.log("Iban number => "   nt.iban);
    console.log("Amount => "   absoluteAmount);

    return partOne   partTwo;
}

The variable partOne represents the account bank number with the slice

The variable nt.iban is the accout bank number

The variable absoluteAmount is the amount for the new transfert

enter image description here

CodePudding user response:

To get rid of any characters that are not digits, you could use

partOne = nt.iban.replace(/\D /g, '').substr(-5, 3);

where \D matches one or more non-digit characters.

  • Related