I have some input elements and would like to include a checkbox that is disabled if the input elements are not complete. However, I cannot use an onClick attribute. A fiddle is below. As you can see, my goal is that the result checkbox should be disabled if input1 and input2 are left blank. Any advice?
fiddle: http://jsfiddle.net/0jozk5uL/
HTML
Input 1:<select name="input1" id="input1" initialvalue="">
<option class="no-op" value="">-- Please select --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><br>
Input 2:<select name="input2" id="input2" initialvalue="">
<option class="no-op" value="">-- Please select --</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select><br>
Result:<input type="checkbox" name="result" id="result">
Javascript
var input1 = document.getElementById('input1');
var input2 = document.getElementById('input2');
var result = document.getElementById('result');
function(){
if(input1 == "" && input2 == ""){
result.disabled = true;
} else {
result.disabled = false;
}
}