This is example for Dropdown validation using JQuery
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"
runat="server">
<title>Validate Dropdownlist in JQuery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">
$(document).ready(function()
{
$('#btnSubmit').click(function() {
if ($("#ddlCountry").val()>0)
{
return true;
}
else {
alert('Please
select Country')
return false;
}
})
});
</script>
</head>
<body>
<form id="form1"
runat="server">
<div>
<table>
<tr>
<td> <b>Select
Country:</b></td>
<td>
<asp:DropDownList ID="ddlCountry"
runat="server">
<asp:ListItem Text="Select" Value="0" />
<asp:ListItem Text="Australia" Value="1" />
<asp:ListItem Text="India" Value="2" />
<asp:ListItem Text="England" Value="3" />
<asp:ListItem Text="USA" Value="4" />
<asp:ListItem Text="China" Value="5" />
<asp:ListItem Text="Sri Lanka" Value="6" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btnSubmit"
Text="Submit"
runat="server"
/>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
No comments:
Post a Comment