JavaScript

They have: 5,633 posts

Joined: Jan 1970

I am using a form with 3 listboxes out of which the user can select from only 1 listbox. If the user selects from more than 1 listbox he'll be alerted "Please select one city from one state" . If he doesn't select any city he'll be alerted "Please select a city". I'm using javascript for this validation. The code is working fine in a PC, but its having problems with MAC machines (only with explorer, in netscape its working fine).

This is the script i'm using
<script language="JavaScript">
function check()
{
count = 0
for (i=0;i1)
{
alert("Please select one city from one state");
return false;
}
return true;
}
</script>

but the last alert comes even if only one city is selected. Please let me know how to solve this problem.

URL: http://www.coimbatoreshoppe.com/calendar/

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

I see you're using just frmHome in your DOM. Try the expanded version: document.forms.frmHome... etc Wink

You've also got a variable set count=0. If you've not already declared this variable elsewhere, then use var count=0. Wink

I can't see anything else obviously wrong, so try it out and post back if you've still got problems. Smiling

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.