Page Design <table>
<tr>
<td>
Select Country
</td>
<td>
<asp:DropDownList ID="ddlCountry" runat="server" AutoPostBack="True" Height="16px"
onselectedindexchanged="ddlCountry_SelectedIndexChanged" Width="123px"></asp:DropDownList>
</td>
</tr>
<tr>
<td>
Select State
</td>
<td>
<asp:DropDownList ID="ddlState" runat="server" AutoPostBack="True" Height="16px"
onselectedindexchanged="ddlState_SelectedIndexChanged" Width="124px"></asp:DropDownList>
</td>
</tr>
<tr>
<td>
Select City
</td>
<td>
<asp:DropDownList ID="ddlCity" runat="server" Height="16px" Width="124px"></asp:DropDownList>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btnSubmit" OnClientClick="return Validate()" Text="Submit" runat="server" onclick="btnSubmit_Click" />
</td>
</tr>
</table>
Javascript Code <script type="text/javascript" language="javascript">
function Validate() {
var country = document.getElementById("ddlCountry").selectedIndex;
var state = document.getElementById("ddlState").selectedIndex;
var city = document.getElementById("ddlCity").selectedIndex;
if (country <= 0) {
alert("Please choose country");
return false;
}
if (state <= 0) {
alert("Please choose state");
return false;
}
if (city <= 0) {
alert("Please choose city");
return false;
}
}
</script>