Last active
October 5, 2018 12:27
-
-
Save wattry/1318ea40d7e9ecca9f9ff8e4a4a8de6d to your computer and use it in GitHub Desktop.
JS function to enable and disable inputs as the previous was filled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateRelationshipForm(inputs) { | |
for (i = 0; i < (inputs.length - 2); i+=2) { | |
if (inputs[i].value.length > 0) { | |
inputs[i + 1].disabled = false; | |
if (inputs[i + 1].type == "button") { | |
inputs[i + 1].classList = ("btn btn-success"); | |
} | |
} else { | |
inputs[i + 1].disabled = true; | |
if (inputs[i + 1].type == "button") { | |
inputs[i + 1].classList = ("btn btn-secondary"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment