Not even close:
Code:
var y=document.forms["myForm"]["product"].value;
You can not get the value of a *GROUP* of form fields of any kind like that. Whether radio buttons, check boxes, or even same-named text fields.
For radio buttons and checkboxes, you can write a function such as this:
Code:
function getGroupValue( group )
{
if ( group.length == null )
{
// just in case it's actually *not* a group:
return group.checked ? group.value : "";
}
// for true groups:
var val = "";
for ( var g = 0; g < group.length; ++g )
{
if ( group[g].checked ) { val += "," + group[g].value; }
}
if ( val != "" ) val = val.substring(1);
return val;
}
For radio buttons, that will return "" if none are checked and the value of the one checked if one is.
For checkboxes, that will return "" if none are checked and a comma delimited list of value if 1 or more is checked.
You would then invoke that via (example from your code):
Code:
function validateForm()
{
var form = document.forms["myForm"];
var x = form.opName.value;
var y = getGroupValue( form.product );
...
Note that neither x nor y will *EVER* be null. No point in testing for it.
Text field values, such as
opName here, can not be null. They can be blank (""), but never null.
And that
getGroupValue() function, as written, can't return a null.