berkshirea
Technical User
Hi guys, I've got the code below.
The first line 'Yes' or 'No' is mandatory. When 'Yes' is clicked, the 2nd line (No, Probably or Yes) becomes mandatory. If 'No' is clicked on the first line, the 2nd line is not mandatory.
I've been trying and I can't get it to work as I want it to. Any help is appreciated. Thanks guys!
The first line 'Yes' or 'No' is mandatory. When 'Yes' is clicked, the 2nd line (No, Probably or Yes) becomes mandatory. If 'No' is clicked on the first line, the 2nd line is not mandatory.
I've been trying and I can't get it to work as I want it to. Any help is appreciated. Thanks guys!
Code:
<script>
function myTest() {
document.getElementById("fruity").required = true;
document.getElementById("fruityJuice").required = true;
}
</script>
<form id="form1" name="form1" method="POST" action="test.html">
<!-- question 1 below is mandatory-->
Yes <input name="fruity" id="fruity" type="radio" value="Yes" />
No <input name="fruity" id="fruity" type="radio" value="No" />
<p>
<!-- question 2 below is mandatory if 'Yes' was clicked in question 1. if 'No', not mandatory -->
No <input name="fruityJuice" id="fruityJuice" type="radio" value="No" />
Probably <input name="fruityJuice" id="fruityJuice" type="radio" value="Probably" />
Yes <input name="fruityJuice" id="fruityJuice" type="radio" value="Yes" />
<input onclick="return myTest();" type="submit" name="Submit" value="Submit" />
</form>