Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Friday, September 13, 2013

Code for java script validation

Code for java script validation:


  <script type="text/javascript">
        function Validate() {

            if (document.getElementById("<%=ddlclassId.ClientID%>").value == "0") {
                alert("Please Select Class.");
                document.getElementById('<%=ddlclassId.ClientID%>').focus();
                return false;
            }

            else if (document.getElementById("<%=ddlsubjectid.ClientID%>").value == "0") {
                alert("Please Select Subject.");
                document.getElementById('<%=ddlsubjectid.ClientID%>').focus();
                return false;
            }

            else if (document.getElementById("<%=ddlmonth.ClientID%>").value == "0") {
                alert("Please Select Month.");
                document.getElementById('<%=ddlmonth.ClientID%>').focus();
                return false;
            }
            else if (document.getElementById("<%=txtClassTestname.ClientID%>").value == "") {
                alert("Please Enter Class Name.");
                document.getElementById('<%=txtClassTestname.ClientID%>').focus();
                return false;
            }
            else if (document.getElementById("<%=txtMaxmarks.ClientID%>").value == "") {
                alert("Please Enter Maximum Marks .");
                document.getElementById('<%=txtMaxmarks.ClientID%>').focus();
                return false;
            }
            else if (document.getElementById("<%=TxtPassMarks.ClientID%>").value == "") {
                alert("Please Enter Passing Marks.");
                document.getElementById('<%=TxtPassMarks.ClientID%>').focus();
                return false;
            }
            else if (document.getElementById("<%=txtdate.ClientID%>").value == "") {
                alert("Please Select Date .");
                document.getElementById('<%=txtdate.ClientID%>').focus();
                return false;
            }
            return true;
        }
 
    </script>

Call java script function in to button onclick:

OnClientClick="javaScript:return Validate();"

Other Related  Post:

No comments:

Post a Comment