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

97
Vistas
e.preventDefault() not working on onClick/onFocus event with an input

Trying to prevent the default behavior of clicking and focusing on an input. I understand that I can use CSS to prevent this (pointer-events: none). I am eventually trying to prevent clicking on input at certain caret positions.

Is there an explanation as to why e.preventDefault() isn't working in this situation?

import React from "react";

function InputText() {

  function handleClick(e) {
    e.preventDefault();
  }

  return (
    <input onClick={handleClick}></input>
  );
}

export default InputText;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Probably you can use the attribute Disable of input to prevent users from clicking and focusing. I think onclick just working well on stuff like buttons.

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