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

307
Views
acceptRegex in DatePicker MUI library not working as intended

I am trying to block invalid date input by using the acceptRegex property in Datepicker but couldn't get it applied. I don't want the user to enter an invalid date like 3022-56-45 by keyboard input.I should be allowing the numbers which forms valid date only. Here is my current implementation.

<LocalizationProvider dateAdapter={AdapterDateFns}>
              <DesktopDatePicker
                label="Date of Birth"
                inputFormat="yyyy-MM-dd"
                acceptRegex="/^d{4}-d{2}-d{2}$/"
                mask={"____-__-__"}
                minDate="1900-01-01"
                value={dateOfBirth ? parseISO(dateOfBirth) : null}
                onChange={(val) => {
                  setDateOfBirth(moment(val).utc().format("YYYY-MM-DD"));
                }}
                renderInput={(params) => (
                  <TextField fullWidth sx={{ pr: 3 }} {...params} />
                )}
              />
            </LocalizationProvider>
about 4 years ago · Juan Pablo Isaza
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!