I have the following dropdown. Client wants to form throw an error if the value fail is selected. I told him easy solution is to remove the fail from the menu :) That way only option is Pass and the problem is solved:) Not really. He still wants both options and if Fail selected he wants to see the required error may be a text saying you need to select Pass.
<div class="section colm colm6">
<label class="field select">
<select id="cond" name="Cond" required>
<option value=''>Condition</option>
<option value='Pass' >Pass</option>
<option value='Fail' >Fail</option>
</select>
<i class="arrow double"></i>
</label>
</div>
I need to do the error check as soon as the file is selected rather than until the whole form is submitted. I have another 2 fail and pass dropdowns and 2 yes and no dropdowns that I need to do the same thing. If I get one working I should be able to the others (I hope)
I am guessing that I need to create a some sort of function similar to
function checkCategory(){
if(document.getElementById('cond').value === 'Fail') {
alert("Client says you need to enter Pass");
return false;
}
}
and may be use an onselect ( I am not sure how to call it ) use onselect="javascript:checkCategory();"
I am pretty much stuck at this point. Your help is much appreciated. Thank you for your time.
onselectit should beonchange;