CaioQuirinoMedeiros / react-native-mask-input

🎭:iphone: A simple and effective Text Input with mask for ReactNative on iOS and Android. Includes obfuscation characters feature.
https://www.npmjs.com/package/react-native-mask-input
MIT License
309 stars 31 forks source link

how to mask iban number #14

Closed ihsanktmr closed 2 years ago

ihsanktmr commented 2 years ago

I can't enter strings with this mask ->

export const IBANMask = [
  /\d/,
  /\d/,
  ' ',
  /\d/,
  /\d/,
  /\d/,
  /\d/,
  ' ',
  /\d/,
  /\d/,
  /\d/,
  /\d/,
  ' ',
  /\d/,
  /\d/,
  /\d/,
  /\d/,
  ' ',
  /\d/,
  /\d/,
  /\d/,
  /\d/,
  ' ',
  /\d/,
  /\d/,
  /\d/,
  /\d/,
  ' ',
  /\d/,
  /\d/,
];

I am trying to mask iban number for example -> GB29 NWBK 6016 1331 9268 19 Can you help me ? thanks

arochedy commented 2 years ago

Did you thind how to do it ??

CaioQuirinoMedeiros commented 2 years ago

@arochedy , read the documentation, understand how the mask works and you should be able to build what you want...

On @ihsanktmr code he used /\d/ for all inputs, but /\d/ will match only numbers.

I do not know IBAN numbers, but you can try something like this:

const ibanMask = [
  /[a-zA-Z]/,
  /[a-zA-Z]/,
  /\d/,
  /\d/,
  ' ',
  /\w/,
  /\w/,
  /\w/,
  /\w/,
  ' ',
  /\d/,
  /\d/,
  /\d/,
  /\d/,
  ' ',
  /\d/,
  /\d/,
  /\d/,
  /\d/,
  ' ',
  /\d/,
  /\d/,
  /\d/,
  /\d/,
  ' ',
  /\d/,
  /\d/,
  /\d/,
  /\d/,
];