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

157
Views
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[object FormData]' is not a valid selector

I have this html-form:

<form id="LoginForm" class="login-form">
    <p>
        <label for="username">Gebruiker:</label><br />
        <input type="text" name="username" autofocus />
    </p>

    <p>
        <label for="password">Wachtwoord:</label><br />
        <input type="password" name="password" />
    </p>

    <p class="submit-wrapper">
        <input
            type="submit"
            value="Verstuur"
            id="SubmitLogin"
            class="submit"
        />
    </p>
</form>

And I want to submit access the data with the FormData-api like this:

const submitLogin = document.querySelector("#SubmitLogin");
submitLogin.addEventListener("click", function (event) {
    event.preventDefault();

    const form = document.querySelector("#LoginForm");
    const data = new FormData(form);
});

Then I get this error in the console:

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[object FormData]' is not a valid selector.
    at HTMLInputElement.<anonymous>

I have been googling and stackoverflowing for a while today. All the solutions I find, involve numbers or illegal signs in the ID. But the form-ID (LoginForm) does not contain any of these. So now I am at a loss and would appreciate any help.

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