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

217
Views
MUI Input doesn't allow oninput attribute

I have an MUI Input component defined like this where the oninput (tried as onInput as well) attribute doesn't get picked by MUI

  <Input
    variant="standard"
    size="small"
    type="number"
    inputProps={{
      min: '0',
      oninput: "validity.valid||(value='');",
    }}
    onChange="validity.valid||(value='');"
  />

As the MUI doc says,

inputProps object {} Attributes applied to the input element.

And well, oninput is a valid Event attribute for the input element but on render, the underlying native HTML input element has only the min attribute defined and the oninput attribute is missing.

What is going wrong here? I even tried it with onChange but to no success.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should pass a function parameter as onInput prop instead of a string like this:

const handleOnInput = (e) => {
    //e.target.value
};

<Input
    value={val}
    variant="standard"
    size="small"
    type="number"
    inputProps={{
      min: "0",
      onInput: handleOnInput
    }}
/>

You can take a look at this sandbox for live working example.

about 4 years ago · Juan Pablo Isaza Report
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!