SO - 13831601

by Rich Costello

HTML

<form id="communitiesSelfRegPage:theForm">

Name: <input type="text" id="communitiesSelfRegPage:theForm:firstName"><br><br>
last: <input type="text" id="communitiesSelfRegPage:theForm:lastName"><br><br>

<input id="communitiesSelfRegPage:theForm:submit" type="submit" name="communitiesSelfRegPage:theForm:submit" value="Submit" onclick="validateemail();" class="btn btn status submit-margin-2">

</form>

JavaScript

// Submit button javascript
var button = document.getElementById("communitiesSelfRegPage:theForm:submit");

// Disable the button on initial page load
button.disabled = true;

//add event listener
document.getElementById("communitiesSelfRegPage:theForm").addEventListener("change", myFunction);
function myFunction() {
  var fname = document.getElementById("communitiesSelfRegPage:theForm:firstName");
  var lname = document.getElementById("communitiesSelfRegPage:theForm:lastName");
  {!$Component.theForm.billingcheck}"
  
  .getElementById("{!$Component.communitiesSelfRegPage:theForm:firstName}");
  

  if(fname.value && lname.value) {
            button.disabled = !button.disabled;
        }
  else{
  button.disabled = true;
  }
        
  
}