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

104
Views
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 answers
Answer question

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 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!