Yeah, I've run into the same problem. My scenario was I had mutiple checkboxes (so you can select more than one), and the name of the field was "address[]" (so I had a array of values on the php side).
The only way I could figure around this problem, was to, rather than use the name of the object directly in Javascript, (ie- document.formname.address.value), I referenced the object via the elements array. eg- --snip-- var checked = false; for(i=0; i<document.formname.elements.length; i++) { if (document.formname.elements[i].type == 'checkbox') { if (document.formname.elements[i].checked) { checked = true; } } } if (!checked) { alert('You must selected at least one checkbox'); return; } --snip-- You can do a similar thing with the select box, by looking for a different "type". hope this helps, Mike > Hi, > In a form i have two elements: > > I > <input type="text" name="name" size=25 value="test"> > > II > <select name="categories[]" multiple size=10> > <? option value = ...?>.... > <? option value = ....?>.... > > Now i want to show an alert message(using javascript) if the text field is > empty or no option is selected from categories list. > > For the text field its working fine as below (the javascript method called > when onsubmit method is called): > > if(theForm.name.value==""){ > alert("You must enter a Title."); > theForm.name.focus(); > return(false); > } > > But for the options list(categories) i have tried my best but i couldnt get > it work. > Can anyone please tell me how i can do it. > > Thanks > anil > > > -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php