Friday, August 29, 2014

JavaScript Tutorial

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="javaDefault.aspx.vb" Inherits="javaDefault" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
<h1>My First JavaScript</h1>

<p>Click Date to display current day, date, and time.</p>

<button type="button" onclick="myFunction()">Date</button>

<p id="demo"></p>
<button type="button" onclick="ImageClick()">ReDirect</button>
<asp:TextBox ID="txtPagingGoto"  Width="215px" runat="server"></asp:TextBox>
       
          <div>
        <asp:TextBox ID="txtFirstName" runat="server" OnClick ="ValidateInput()"  ></asp:TextBox>
    </div>          

    </div>
    </form>


    
<script type="text/javascript">
    function myFunction() {
        document.getElementById("demo").innerHTML = Date();
    }

    function ImageClick() {
        window.location.href("http://www.google.com/");
    }
  

    function ValidateInput() {
        var validationMessage = "";
        var isValid = true;
        // keep as many as you want
        var inputControls = ['<%= txtFirstName.ClientID %>', '<%= txtFirstName.ClientID %>'];
        for (var i = 0; i < inputControls.length; i++) {
            if (document.getElementById(inputControls[i]).value = '') {
                // update the message
                isValid = false;
            }
        }
        if (!isValid)
            alert(validationMessage);
        return false;
    }
</script> 




</body>
</html>

No comments: