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

212
Views
¿Cómo hago para que el número de tipo de campo de texto de Mui solo acepte el número? ¿Actualmente acepta números, "e" y guiones?

Este es mi código actual.

 <TextField error={values[1].error} fullWidth id="id" type="number" value={values[1].Id} placeholder='Enter ID' onChange={handleChange(1,'Id')} variant="outlined" inputProps={{min: 0,inputMode: 'numeric', pattern: '[0-9]'}} onBlur={() => handleOnBlurEvent(1,'Id')} />

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

0

Como menciona jonrsharpe , los números que contienen - o e siguen siendo números válidos.

Si aún desea limitar los cambios que se aceptan, puede utilizar una función handleNumberChange personalizada que filtra caracteres como e , E y - .

 const handleNumberChange = (id: number, key: string, value: string) => { if (["e", "E", "-"].some((char) => value.includes(char))) return; // handle change here };

Lo usarías así en tu MUI <TextField/> :

 <TextField ... onChange={(e) => handleNumberChange(1, "Id", e.target.value)} />
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!