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

188
Views
React Form submits automatically, prevent automatic submission

I have a form which has a rich text editor and a form submit button, the rich text editor has style buttons which when clicked submit the form inputs (which is not desirable).

I want to prevent this behaviour I want the form to submit only when the submit button is clicked and not when the RTE style button is clicked.

Code:-

Form Code

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

0

Try disabling the button text editor's button.

about 4 years ago · Juan Pablo Isaza Report

0

I've moved the RichEditor out of the form. You can still handle the form submit, I've added the onClick listener on submit button itself. Just copy and paste this return statement in your App.js

return (
    <>
      <div>
        <form>
          <label htmlFor="contact">
            Full Name <span id="required-input-star">*</span>
          </label>
          <br />
          <input
            type="text"
            value={name}
            onChange={(e) => setName(e.target.value)}
            required
          />
          <br />
          <label htmlFor="contact">
            Email <span id="required-input-star">*</span>
          </label>
          <br />
          <input
            type="text"
            value={email}
            onChange={(e) => setEmail(e.target.value)}
            required
          />

          <br />
          <label htmlFor="description">
            Description <span id="required-input-star">*</span>
          </label>
          <br />
        </form> //closed the form here, and moved out RichEditor


       <RichTextEditor />

        <hr />
        <div className="frm-btn-container">
          <input type="submit" value="Cancel" id="cancel-btn" />
          <input type="submit" value="Create" onClick={onSubmit} />
        </div>
      </div>
    </>
  );
};


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!