Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai i am using DropDownList and i am validating the DropDownlist at the time it's throw one Error for:Undefined this is my Error Please Help me where i done mistake below is my code and Java script :

UI:
XML
<asp:DropDownList ID="ddrlclientststus" runat="server" CssClass="txtboxadddetails">
                                <asp:ListItem>--Select--</asp:ListItem>
                                <asp:ListItem>Open</asp:ListItem>
                                <asp:ListItem>Closed</asp:ListItem>
                            </asp:DropDownList>

JavaScript
<script type="text/javascript">
        function validate() {
            debugger;
            var summary = "";
            summary += isvalidClient();
            summary += isvaliedUserName();
            summary += isvaliedStatus();
if (summary != "") {
                alert(summary);
                return false;
            }
            else {
                return true;
            }
        }
function isvalidClient() {
            var CliID
            var temp = document.getElementById("<%=txtClientId.ClientID%>");
            CliID = temp.value;
            if (CliID == "") {
                return ("Please Enter Client ID" + "\n");
            }

            else {
                return "";
            }
        }

        function isvaliedUserName() {
            var CliID
            var temp = document.getElementById("<%=txtClientName.ClientID%>");
            CliID = temp.value;
            if (CliID == "") {
                return ("Please Enter Client Name" + "\n");
            }

            else {
                return "";
            }
        }
//it's error Showing hear only this funcation(isvaliedStatus)
 function isvaliedStatus() {
            if (document.getElementById('<%=ddrlclientststus.ClientID %>').selectedIndex == 0) {
                return ("Please Select Ststus" + "\n");
            }
        }
Posted
Updated 8-Aug-13 21:28pm
v4
Comments
Thanks7872 9-Aug-13 3:31am    
I don't know why to do such a tedious work just to validate dropdownlist?
vaibhav10Dec1987 9-Aug-13 6:37am    
have you add jquery.min.js file??
Maarten Kools 9-Aug-13 8:25am    
What line is exactly giving you the error? Have you debugged it using the developer tools available in your browser?

1 solution

JavaScript
function isvaliedStatus() {
           if (document.getElementById("ddrlclientststus").selectedIndex == 0) {
               return ("Please Select Ststus" + "\n");
           }
       }

Happy Coding!
:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900