function submitcheck() {
var f = document.form1;
if (f.rbTemplate!= null)
{
...
alert('Please choose template');
return false;
...
}
if (f.rbColorId!= null)
{
...
alert('Please choose template color');
return false;
...
}
}
function ShowColor()
{
var f= document.form1;
iTemplate= getSelectedRadioValue(f.rbTemplate);
var params= "iTemplate="+iTemplate;
var url= "ajaxColor.php";
doShowOutput(params, url, retrieveColorsAvailableForThisTemplate);
}
function retrieveColorsAvailableForThisTemplate()
{
if(httpObject.readyState == 4)
{
document.getElementById('showtime').style.display="";
document.getElementById('showtime').innerHTML= httpObject.responseText;
}
}
<input type='radio' name='rbTemplate' id=1 value=1 onclick='ShowColor();'>
<img src="template1.jpg" />
<br />
<input type='radio' name='rbTemplate' id=2 value=2 onclick='ShowColor();'>
<img src="template2.jpg" />
<div id=showtime></div>
when click on rbTemplate id=1, ajax query will return the available colors for this template into id=showtime
eg:
<table>
<tr>
<td bgColor="#FF0000"><input type=radio name=rbColorId id=1 value=1></td>
<td bgColor="#FF0007"><input type=radio name=rbColorId id=2 value=2></td>
<td bgColor="#FF0003"><input type=radio name=rbColorId id=3 value=3></td>
</tr>
</table>
when click on rbTemplate id=2, ajax return the output as simple message into id=showtime, because this template actually don't have any color selection)
eg: "<p>this template don't have any color</p>"
Problem now is :
Step 1: after I click on rbTemplate id=1 and without select color, then click submit (javascript will prompt me to select color),
Step 2: then I repeat again by clicking on rbTemplate id=2, click submit again, at this time, it shouldn't prompt for color selection, because this second template don't have color. BUT javascript prompt still appear. JS validation still able to detect f.rbColorId (maybe from cache or...)... Help...
Help