The only thing that you have to check is if the selectedindex is -1 which
is the value if no item is selected.

/Markus Ridal

> I was wondering if any one could help me.
> I need to make sure that a select box has items highlighted when the
> HTML page is submitted. I have tried this but it does not work, could
> someone help me out please.
>
> <script language="Javascript">
>
>  function validate(this_form) {
>       // required form values
>           var User =
> this_form.gmrpeople[this_form.gmrpeople.selectedIndex].value;
>   //gmrpeople is the select box
>  //begin validation
>        if (!( User == "")) {
>        return true;
>       }
>       else {
>            msg = "\nYou need to highlight an option in the
> selectbox:\n";
>            alert(msg);
>            return false;
>      }
>  }
>
> </SCRIPT>
>
> And with the FORM
>
> <FORM onSubmit="return validate(this)" ACTION="/vdb/newlite"
> METHOD="post">
>
> If anyone could help I would be most appreciative.
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to