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

232
Visualizações
react-input-mask date input mask regex

I have a date input with react-input-mask.

Here is my code:

   <div className="date-picker-container" tabIndex={1}>
      <InputMask
        className={className}
        id={id}
        onKeyDown={(e) => disabledInput && e.preventDefault()}
        mask="XX.XX.XXXX"
        formatChars={{
          X: "[1-31]",
          X: "[1-12]",
          X: "[1-2200]",
        }}
        {...register(name, validation)}
        value={innerValue}
        onChange={handleInputChange}
        placeholder="gün.ay.il"
        onClick={
          className.includes("is-invalid") ? () => setFocused(true) : () => {}
        }
      />
      <span className="date-icon" onClick={() => setFocused(!focused)}>
        <Calendar />
      </span>
      <div className={focused ? "d-block" : "d-none"}>
        <CR
          locale={locale}
          date={date}
          maxDate={maxDate || null}
          minDate={minDate}
          onChange={handleChange}
          displayMode="date"
        />
      </div>
    </div>

With the 'formatChars' property in reac-input-mask, I want to write a regex to the data that the user will type with the keyboard.

for example. the user can write max 31 for the number of days, max 12 for the month, and 2200 for the year.

I tried the way I specified in the example, but I couldn't get the result I wanted. how can I do that?

about 4 years ago · Santiago Gelvez
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