Inputmask
Inputmask copied to clipboard
Switch Mask on typing
Hi there. I need a field where you can put an accountnumer or an iban. I need to switch the masks on user is typing. If the mask starts with a letter instead of a number I need the iban mask, else the number mask.
Tried something like this, but this didn't work
$('.js-bankField.iban').on('keydown', function(){
let val = $(this).val();
let firstSigns = val.substring(0, 1);
let mask = (parseInt(firstSigns)==firstSigns) ? '**9999999999999999999999999999999999999999' : '**99 9999 9999 9999 9999 99'
Inputmask({'mask': mask}).mask($(this))
});
I think you could use the solution from https://github.com/RobinHerbots/Inputmask/issues/2109#issuecomment-492563071 and add the account mask to the validMasks
.
@andreknieriem ,
Try something like this
Inputmask([ '9{10,40}' , 'aa99 9999 9999 9999 9999 99'],{
casing: "upper"
}).mask("test1");