Hi.,
Need to do validation in javascript / codebehind (vb.net)
onfocus of Amount textbox i have to make alert as "select Product" if Product dropdown is not selected with any value
Onfocus of Amount textbox i have to make alert as "select Product" if Product dropdown is not selected with any value
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Blocked AccountRank #403 · 6.2K reputationPosted Dec 26, 2011, 2:15 AM EST
you can do this like that
<script type="text/javascript">
function check() {
if ((document.getElementById("DropDownValue").selectedIndex)== 0) {
alert("Please select the Name!");
return false;
}}
script>
<asp:DropDownList ID="DropDownValue" runat="server">
<asp:ListItem Text="Manish" Value="Manish">asp:ListItem>
<asp:ListItem Text="Gaurav" Value="Gaurav">asp:ListItem>
<asp:ListItem Text="Ravi" Value="Ravi">asp:ListItem>
asp:DropDownList>
<asp:TextBox onfocus="Javascript:check();" ID="TextBoxAlert"
runat="server">asp:TextBox>
i think you will get some idea from this solution.