Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

229
Visualizações
Getting Input Value without Space

I'm trying to get customer credit card number with MaskedInput and I need to delete spaces before using it on calling service but even though I don't actually change event value whenever customer tries to delete it, they can't because in value spaces doesn't exist. I only want to get value without space and set it into state. How can I do that?

 <MaskedInput inputMode="numeric" type="text" onChange={(e) => this.checkCC(e)} mask={[/\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/, ' ', /\d/, /\d/, /\d/, /\d/]} required></MaskedInput>

checkCC(e) {
        this.setState({
            creditCard: event.target.value.replaceAll(" ", "")
        });
    }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I believe your mask is incorrect. Try something like this

          mask={[
            {
              length: 4,
              regexp: /^[0-9]{4}$/,
              placeholder: "xxxx"
            },
            { fixed: " " },
            {
              length: 4,
              regexp: /^[0-9]{4}$/,
              placeholder: "xxxx"
            },
            { fixed: " " },
            {
              length: 4,
              regexp: /^[0-9]{4}$/,
              placeholder: "xxxx"
            },
            { fixed: " "},
            {
              length: 4,
              regexp: /^[0-9]{4}$/,
              placeholder: "xxxx"
            }
          ]}
about 4 years ago · Juan Pablo Isaza Relatório

0

You can use the trim() function:

    this.setState({
        creditCard: event.target.value.trim()
    });
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda