JavaScript Basics, Login verification

Source: Internet
Author: User
Tags button type

Three ways to use <script></script>:

  1. Put in the <body>
  2. Put in the
  3. Placed in an external JS file
    <! DOCTYPE html>"en">"UTF-8"> <title> my </title> <script>function Displaydate () {document.getElementById ("Demo"). innerhtml=Date (); }    </script> <script src="24.js"></script>"Demo">ppp</p> <script>document.write (Date ()); document.getElementById ("Demo"). innerhtml=Date (); </script><buttom type="Button"Onclick=window.alert (" Number") >press</buttom></body>Copy Code function myFunction () {Document.getelementbyld ("Demo"). innerhtml="my first JavaScript function";}

    Three ways to output data:

    1. Use the document.write () method to write content to an HTML document.
    2. Use the Window.alert () pop-up warning box.
    3. Writes to an HTML element using InnerHTML.
      1. Use the ID property to identify the HTML element.
      2. Use the document.getElementById (ID) method to access HTML elements.
      3. Use innerHTML to get or insert element content.
        Copy Code<! DOCTYPE html>"en">"UTF-8"> <title> my </title>"Demo">ppp</p> <script>//document.write (Date ());document.getElementById ("Demo"). innerhtml=Date (); </script><buttom type="Button"Onclick=window.alert (" Number") >press</buttom></body>Copy Code

            1. The login page prepares:
              1. Add an Error prompt box.
              2. Write a good html+css file.
              3. Set the ID of each INPUT element
            2. Defines a JavaScript function.
              1. Verify user name 6-20-bit
              2. Verify password 6-20-bit
            3. The onclick invokes this function.
        <! DOCTYPE html>"en">"UTF-8"> <title> Login </title> <script>function Fnlogin () {varOuname=document.getelementbyid ("uname")            varOerror=document.getelementbyid ("Error_box")            if(ouname.value.length<6) {oerror.innerhtml="user name at least 6 bits"            }            if(ouname.value.length>6&opassward.value.length<6) {oerror.innerhtml="password is at least 6 bits"            }        }    </script>class="Box"> class="Input_box"> <input id="uname"Type="text"Placeholder="Please enter user name"> </div> <divclass="Input_box"> <input id="UPass"Type="Password"Placeholder="Please enter your password"> </div> <div id="Error_box"><br></div> <divclass="Input_box"> <button onclick="Fnlogin ()"> Login </button> <button type="Button"Onclick=window.alert ("account password is empty, please enter! ") > not entered the account password </button> </div></div></body>

JavaScript Basics, Login verification

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.