Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

230
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda