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

151
Views
Disabling buttons based on input values doesn’t work on two forms

First and foremost: I’m using Webflow, so the issue can be related to Webflow somehow.

Second, I’m still learning to code, so please keep in mind that I’m still a newbie.

I’m using two same forms (different classes since, well, they are two separate elements) on a site because the one is static and another one is located in CMS (Collection List).

The thing is, they did work together before, but I did something, and… well, you know — I’ve tried to debunk what happened, but didn’t find a proper solution.

For some, very-very strange reason, only the latter works, e.g., if jobs-form-cms-button is the first, then it won’t work, but jobs-form-button will. And vice versa.

function checkform() {
    const formElements = document.forms["wf-form-jobs"].elements;
    let submitBtnActive = true;

    for (let inputEl = 0; inputEl < formElements.length; inputEl++) {
        if (formElements[inputEl].value.length == 0) submitBtnActive = false;
    }

    if (submitBtnActive) {
        document.getElementById("jobs-form-button").disabled = false;
    } else {
        document.getElementById("jobs-form-button").disabled = "disabled";
    }
};

function checkform() {
    const formElementsCMS = document.forms["wf-form-cms-jobs"].elements;
    let submitBtnActiveCMS = true;

    for (let inputEl = 0; inputEl < formElementsCMS.length; inputEl++) {
        if (formElementsCMS[inputEl].value.length == 0) submitBtnActiveCMS = false;
    }

    if (submitBtnActiveCMS) {
        document.getElementById("jobs-form-cms-button").disabled = false;
    } else {
        document.getElementById("jobs-form-cms-button").disabled = "disabled";
    }
};

I’ve renamed some vars and const because it didn’t work otherwise. Also, I did some stuff in order to make this code work with Webflow since I couldn’t add some attributes to the native Webflow elements, e.g., “Form Button” (“disabled” attribute was reserved for the system) — so I added the forms by myself via custom code element.

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

0

Both functions have the exact same name, in JavaScript when both functions have the same name, the 2nd function will override the first function.

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!