JavaScript Document Object Part – 1

Free Web development courses with real-time projects Start Now!!

Program 1

<html>
    <head><title>Java Script date Demo</title>

        <script language="javascript">
           //alert(window.document.URL)
            // alert(document.URL)
        //     function xyz()
        //    { 
        //        var user
        //        user=document.getElementById("USER").value
        //        document.writeln(user)
        //    }   
          function validate()
          {
              var user,pass;
              user=document.getElementById("USERNAME").value
              pass=document.getElementById("USERPASSWORD").value
              if(user==="dataflair" && pass==="indore")
              document.writeln("<font color=green size=5>You are valid user</font>")               
             else
             document.writeln("<font color=red size=5>Invalid user id or password</font>")               
             // document.writeln("User Name="+user)
             // document.writeln("<br>Password="+pass)

             // factorial
             // palindrom
          }
        </script>
    </head>
        <body>
            <center>
              <table border=1>  
               <form> 
                  <tr>
                  <th>User Name</th>
                  <td><input type="text" name=txtuser id="USERNAME"></td>  
                  </tr>
                  <tr>
                    <th>Password</th>
                    <td><input type="password" name=txtpass id="USERPASSWORD"></td>  
                    </tr>
                    <tr><td><input type="button" value="Submit" onclick="validate()"></td></tr>
                </form>  
            </table>
             </center>   
        </body>
</html>

 

We work very hard to provide you quality material
Could you take 15 seconds and share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *