Check with javascript entry combobox/radiobutton

Hi,

I’ve a submit button with validate some text field, but how can you check with javascript if the user has filled a combobox or radiobutton.

Rgds,

Rudy

Subject: Check with javascript entry combobox/radiobutton

for (i=0;i<document.forms[0].FieldName.length;i++){ x=“”;

            if(document.forms[0].FieldName[i].checked){

                    x = document.forms[0].FieldName[i].value;

                    break;

            }      

    }

    if(x== ""){

            alert("Select FieldName");

            return;

    }

HTH

Keshava

Subject: RE: Check with javascript entry combobox/radiobutton

yes this works fine for the radiobutton, but not for the combobox…I’ve a default value in the combobox “-----”

Subject: RE: Check with javascript entry combobox/radiobutton

Im stuck with the same problem, help!

Subject: Check with javascript entry combobox/radiobutton - SOLUTION

First here is the validation code on a Combobox (named “State”) that did not work. It would never pass validation no matter what state was chosen:

if (f.State.value==“”) {

	msg += "State\n";

	flag = false;

	}

The following is the code that did the trick, after all that, it just needed to be treated as an array:

if ((f.State[f.State.selectedIndex].text == “”)){

	msg += "State\n";

	flag = false;

	}

There might be a better way somewhere out there but I couldn’t find one. Hopefully this will help someone.