Trying to make sure a radio button is always checked on a form submit. I cant seem to get this to work. Please advise how I can correct this?
[code]
<script>
j=document.webpagename;
function validater(j)
{
for(x=0;x<j.color.length;x++)
{
if(j.color[x].checked)
var checked=true;
if(!checked)
{
alert(‘One color has to be selected.’);
return false;
};
}
<form method=”post” action=”actionpage” onsubmit=”return validater(this)”
<blockquote>
<input name=”color” type=”radio” value=”red”>
<input name=”color” type=”radio” value=”green”>
<input name=”color” type=”radio” value=”blue”>
<input name=”color” type=”radio” value=”black”>
</blockquote>