>Hi All,
>
> I've come across a problem with validating fields in Javascript. I have a Dropdown on a webpage which allows the user to select a State for an address. If the State is left blank then an alert notifies the user to enter the state and the page is not submitted. It works fine in IE but in Netscape 4.7 & 6.0 if the state is empty the page is still submitted. If have similar validation on text fields and these work fine in Netscape, it's just dropdowns I'm having a problem with. Any ideas?
>
>
>if (mywebpage.State.value == "")
>{
> alert("Please enter a State.");
> mywebpage.State.focus();
> return (false);
>}
>
>
>I've come across a number of quirks with the way javascript works ( or doesn't work ) in different browsers. I'm thinking of doing my validation on the server instead of the browser due to the fact that with client side validation you have to account for the different versions of browser. Which option is the safest, client side or server side validation?
>
>Thanks,
>Gavin...
Have you tried checking the "selectedIndex" attribute being equal to -1, for no element selected - this is defined in the DOM specification ? If no element is selected, then it doesn't appear that "value" is defined - in other browsers it may be null rather than an empty string (NOTE I'm guessing here, but from experience of trying to develop cross-browser javascript).
Len Speed