form validation

They have: 117 posts

Joined: Feb 2000

Hello,

I know this is simple (in fact I think i've done it before, but can't remember how, and can't find the old code). Does anyone know the syntax for validating input from the tag of a form? For example, if I had something like this in a form:

Select a color
red
blue

How can I use javascript to check to ensure a choice was selected? Thanks.

Bob

They have: 117 posts

Joined: Feb 2000

Hello,

Thanks to anyone who was going to help with this, but I remembered myself. You can use:

if (document.formName.fieldName[0].selected == false &&
document.formName.fieldName[1].selected == false){
alert("You must choose one option");
return false;}

Thanks,

Bob

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.