I have made a HTML form with several input fields like these:
<tr>
<td>inputfield1</td>
<td><input type="number" class="bestelformulier" name="inputfield1" onkeyup="validateForm()" min="1" max="999"></td>
</tr>
<tr>
<td>inputfield2</td>
<td><input type="number" class="bestelformulier" name="inputfield2" min="1" max="999"></td>
</tr>
<tr>
<td>inputfield3</td>
<td><input type="number" class="bestelformulier" name="inputfield3" min="1" max="999"></td>
</tr>
<tr>
<td>inputfield4</td>
<td><input type="number" class="bestelformulier" name="inputfield4" min="1" max="999"></td>
</tr>
As you can see my input field 1 has an onkeyup event called 'validateForm()' which does the following:
function validateForm(){
if(document.forms['form'].inputfield1.value == "")
{
document.forms[0].submit.disabled=true;
}
else {
document.forms[0].submit.disabled=false;
}
}
It disables the button if nothing is filled in inputfield1 but enables it if there is something in there.
This works just as it should.
But as you can see i have several inputfields which all need a function like that.
The button needs to be disabled when 0 out of 11 fields are filled but needs to be enabled if even 1 of them is filled (doesn't matter which one)
How do I make it so that if 1 of those 11 fields are filled the button will enable?
All help is grealy appreciated!
validateForm. Otherwise, your best bet is to move thevalidateFormcall to the form "onsubmit" event, and check all the fields then.