Text-mask: Unmasked Value

Created on 16 Feb 2017  路  6Comments  路  Source: text-mask/text-mask

Can i get unmasked user input ?

given:
let mask = ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]

masked value after user input:
(555) 123-4567

what i would like to get:
5551234567

Most helpful comment

@refo

let onlyNumbers = userInput.replace(/\D/g, '');

All 6 comments

Just use a regex to wipe out unwanted chars.

@refo

let onlyNumbers = userInput.replace(/\D/g, '');

Thank you guys. I was wondering if the library collects each char separately as user inputs and the char conformed to mask. For some reason, it didn't occur to me that unmasked values may vary for different masks : )

馃憤

Guys, if i mask the number with *, and then if i do a unmask, how do i get orignal value ?
thanks in advance!!!

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AliveDD picture AliveDD  路  5Comments

KevinGruber picture KevinGruber  路  6Comments

badre429 picture badre429  路  3Comments

caub picture caub  路  4Comments

jvbianchi picture jvbianchi  路  5Comments