Question : Javascript form validation problems

Okay, so I posted this question previously and the attached code is as far as the previous 'expert' got before running out of steam. The issue here is pretty simple: I don't want the image next to each text box and set of radio buttons to change until the radio button has been selected AND the text box has been typed in. Right now it changes as soon as the radio button has been selected.

All of the fields on the page are part of one form.

Also, it doesn't work in Firefox, so any help there would be appreciated as well.
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:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	var radio_val;
	window.onload = function() {
		document.body.onclick = function(e) {
			var i = (window.event)?(window.event.srcElement):(e.srcElement);
			if( i.type == "radio" ) {
//				if( i.name == "radio" ) {
					var trc = i.parentNode.parentNode.parentNode.parentNode;
					var trs = trc.parentNode.parentNode.parentNode.getElementsByTagName("tr");
					for(i=0;i<trs.length-1;i++) {
						if( trs[i] == trc ) {
							var td = trs[i+1].getElementsByTagName("td")[4];
							var img = td.getElementsByTagName("img")[0];
							img.src = "http://www.astuceswarcraft.fr/images/valid.png";
						}
					}
//				}
			}
		}
	}
</script>
</head>
<body>
<table width="99%"  border="0" align="center" cellpadding="1" cellspacing="1" border="1">

                    
                            <tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #147939 by:<br> <a href="designer.php?id=4164"><font color="#000000" size="3">rizkimuliawan</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>
        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />
        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />

        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100505052637.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">
 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr><tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #147943 by:<br> <a href="designer.php?id=4034"><font color="#000000" size="3">engleeinter</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>

        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />
        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />
        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100505053200.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">

 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr><tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #147944 by:<br> <a href="designer.php?id=4034"><font color="#000000" size="3">engleeinter</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>
        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />

        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />
        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100505053244.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">
 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr><tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #148142 by:<br> <a href="designer.php?id=4620"><font color="#000000" size="3">nurbografx</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>

        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />
        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />
        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100505121304.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">

 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr><tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #148148 by:<br> <a href="designer.php?id=4620"><font color="#000000" size="3">nurbografx</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>
        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />

        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />
        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100505121905.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">
 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr><tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #148167 by:<br> <a href="designer.php?id=4034"><font color="#000000" size="3">engleeinter</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>

        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />
        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />
        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100505125555.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">

 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr><tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #148236 by:<br> <a href="designer.php?id=4686"><font color="#000000" size="3">tenong</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>
        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />

        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />
        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100505143240.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">
 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr><tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #148304 by:<br> <a href="designer.php?id=1565"><font color="#000000" size="3">ConspiracyInspiration</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>

        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />
        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />
        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100505153129.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">

 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr><tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #148585 by:<br> <a href="designer.php?id=4285"><font color="#000000" size="3">Detjoepoe</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>
        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />

        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />
        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100506011044.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">
 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr><tr bgcolor="#FFFFFF"background="http://www.mycustomlogo.com/images/bgbar.jpg"><td><p></td><td></td></tr><tr ><td width="250" valign="bottom" ><p><div> <font color="#000000" size="3">Entry #148595 by:<br> <a href="designer.php?id=4285"><font color="#000000" size="3">Detjoepoe</font></a></font></div><p></td><td><font face="Arial, Helvetica, sans-serif" size="3">Please rate this entry on a scale of 1 to 5 (5 is best):<strong>

        1
        
        <input type="radio" name="radio" id="radio" value="radio" />
        2
        <input type="radio" name="radio" id="radio2" value="radio" />
        3
        <input type="radio" name="radio" id="radio3" value="radio" />
        4
        <input type="radio" name="radio" id="radio4" value="radio" />
        5
        <input type="radio" name="radio" id="radio5" value="radio" />
     </strong> </font></td></tr><tr><td bgcolor="#000000"><img id="thumb_20596"  class="img2" src="../entry/S2066-20100506014929.jpg" border="0" width="250" height="200" alt="Logo Design Contest Entry" ></a></td><td><table width="824" border="0" height="200" cellspacing="0" cellpadding="0">

 
    <tr>
      <td align="right" valign="bottom" width="250"><textarea name="textarea" id="textarea" cols="40" rows="7" onclick=\"document.myform.textarea.value='';"\ class="ta8">Please comment on this entry. You must enter something.</textarea></td><td align="center"> </td><td align="center"><img src="http://www.blog.wareseeker.com/wp-content/uploads/2009/10/error1.png"></td>    </tr>  </table></td></tr></td></tr>          <tr>
            <td  valign="top" >          
    </table></td>
  </tr>
</table>&nbsp;</td>
        </tr>

</table>
<label>
<div align="center"></div>
</label>

<div align="left">
  <p>&nbsp;  </p>
  <p align="center">
    <input name="button" type="submit" class="groovybutton" id="button" value="View Next 10 Entries &gt;&gt;">
  </p>
     </td>

  </tr>
</table>     </td>
  </tr>
</table>
</body>
</html>

Answer : Javascript form validation problems

I believe you should use the following code sample to achieve.
1:
sp_help 'MiEsqueme.ALCANCE'
Random Solutions  
 
programming4us programming4us