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

68
Visualizações
Change one charter in state while typing - reacjs

I have a state:

const [numIndexZero, setNumIndexZero] = useState("****");

And I have an input that I type 4 numbers.

How can I change each charter when i typing a number?

Meaning that, if I type "1" then the state will be "1***" .

If I type "12" then the state will be "12**" ,

If I type "123" then the state will be "123*" ,

If I type "1234" then the state will be "1234".

Any help??

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can do it by using padEnd methid like this:

<input onChange={(e)=>setNumIndexZero(e.target.value.padEnd(4,"*"))} .../>
about 4 years ago · Juan Pablo Isaza Relatório

0

Calling setState with the value directly updates the value. For eg:

setNumIndexZero('1***');
setNumIndexZero('12**');
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