Question : How can I make radio buttons mandatory fields?

Hi Experts,
I have these radio buttons on my page and my users tend to skip checking the No value. How could I make it mandatory? Please see the code below, what do I have to add?
Thank you.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
<html>
<head>
<title>Radio Button</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function uncheckRadio() {
 var choice = document.form1.Sleepy;
 for (i = 0; i < choice.length; i++) {
  if ( choice[i].checked = true )
   choice[i].checked = false;
 }
}

function uncheckRadio1(){
 var choice = document.form1.Thirsty;
 for (i = 0; i < choice.length; i++) {
  if ( choice[i].checked = true )
   choice[i].checked = false;
 }
}

function uncheckRadio2(){
 var choice = document.form1.Hungry;
 for (i = 0; i < choice.length; i++) {
  if ( choice[i].checked = true )
   choice[i].checked = false;
 }
}

//-->
</script>
</head>

<body>

<form method="post" action="MyPage.asp">
<table>
<tr><td align="right">
<b>Are you sleepy?&nbsp;&nbsp;</b>
</td><td>
<label>
<input type="radio" name="Sleepy" value="Yes" ondblclick="uncheckRadio();"><b>Yes</b></label>
</td><td>&nbsp;&nbsp;&nbsp;
<label><input type="radio" name="Sleepy" value="No" ondblclick="uncheckRadio();"><b>No</b></label>
</td></tr>
<tr><td colspan="3">&nbsp;</td></tr>
<tr><td align="right">
<b>Are you thirsty?&nbsp;&nbsp;</b>
</td><td>
<label>
<input type="radio" name="Thirsty" value="Yes" ondblclick="uncheckRadio();"><b>Yes</b></label>
</td><td>&nbsp;&nbsp;&nbsp;
<label><input type="radio" name="Thirsty" value="No" ondblclick="uncheckRadio();"><b>No</b></label>
</td></tr>
<tr><td colspan="3">&nbsp;</td></tr>
<tr><td align="right">
<b>Are you hungry?&nbsp;&nbsp;</b>
</td><td>
<label>
<input type="radio" name="Hungry" value="Yes" ondblclick="uncheckRadio();"><b>Yes</b></label>
</td><td>&nbsp;&nbsp;&nbsp;
<label><input type="radio" name="Hungry" value="No" ondblclick="uncheckRadio();"><b>No</b></label>
</td></tr>
</table>
<input type="submit" name="Submit" id="flashingtext" value="Submit" />

</body>
</html>

Answer : How can I make radio buttons mandatory fields?

MVC is a key pattern for software development.  As you know, it means responsibilities are divided between the Model (the business rules), the View (the UI) and the Controller (the user actions).

I would change your design as shown in your diagram a bit to not go to the level of a Label.

Read more here:
http://www.javaworld.com/javaworld/jw-07-2000/jw-0721-hmvc.html
Random Solutions  
 
programming4us programming4us