<script type="text/javascript">
function Validate()
{
if(document.getElementById('<%=ddlCountry.ClientID%>').value=="0")
{
alert('Please Select Country');
return false;
}
else if(document.getElementById('<%=ddlState.ClientID%>').value=="0")
{
alert('Please Select State');
return false;
}
else if(document.getElementById('<%=txtcityName.ClientID%>').value=="")
{
alert('Please Enter City Name');
return false;
}
return true;
}
</script>
button should be like this
<asp:button id="imbBtnSubmit" runat="server" onclick="imbBtnSubmit_Click" onclientclick="javascript:return Validate();" xmlns:asp="#unknown" />
you are asking for this script i think plz check this
function Validate()
{
var test="";
if(document.getElementById('<%=ddlCountry.ClientID%>').value=="0")
{
test="country,";
}
if(document.getElementById('<%=ddlState.ClientID%>').value=="0")
{
test=test+"state,";
}
if(document.getElementById('<%=txtcityName.ClientID%>').value=="")
{
test=test+"city,";
}
if(test=="")
return true;
else
{
if(test.length>0)
test= test.substr(0,test.length-1);
alert(test +" field(s) are mandatory please fill those");
return false;
}
}