Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Field Validation using JavaScript
Message
From
14/08/2001 09:45:55
 
 
To
13/08/2001 20:35:56
Gavin Reid
L & M Marketing Pty Ltd
Frenchs Forest, Australia
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00543304
Message ID:
00543475
Views:
22
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform