Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!