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

120
Views
HTML check if data were sent instead of using onclick

I'm using onclick on a submit button to make a loading element with javascript on the page before retreiving data from an extract.

However I added a pattern on some input on the form associated with this submit button and the problem I have is that, if the pattern doesn't match (the form doesn't send wrong data, which is good) but this trigger the onclick event generating my loading element for nothing, and that could confuse users.

How can I know for sure that the information of my form has been sent allowing me to start my loading function?

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

0

Try something similar:

<button type="submit" onclick="handleSubmit(event)">Submit</button>

In your JS code:

function isFormValid() {
    // Put here the logic of form validation, which return a boolean value
}

function handleSubmit(event) {
    if (!isFormValid()) {
        event.preventDefault();
        return;
    }
}
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!