JavaScript Basics, Login front-end verification

Source: Internet
Author: User
Tags button type

    1. Three ways to use <script></script>:
      1. Put in the <body>
      2. Put in the
      3. Placed in an external JS file
    2. 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.

    3. 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
    4. Defines a JavaScript function.
      1. Verify user name 6-20-bit
      2. Verify password 6-20-bit
    5. The onclick invokes this function.


<! DOCTYPE html>"en">"UTF-8"> <title> time </title> <script type="Text/javascript"Src=".. /static/js2.js"></script>document.write (Date ())</script> <p></p><button type="Button"Onclick=window.alert ("user name cannot start with a number") > Login </button></body>
<! DOCTYPE html>"en">"UTF-8"> <title> Guangzhou Business School </title>"Demo">hello world!</p> <script>document.getElementById ("Demo"). innerhtml=Date (); </script><button type="Button"Onclick=window.alert ("An error occurred on the access page") > Login </button></body></body>
<! DOCTYPE html>"en">"UTF-8"> <title>login</title> <link href=".. /static/css/login.css"Rel="stylesheet"Type="Text/css"> <script>function Fnlogin () {var ouname= document.getElementById ("uname") var oerror= document.getElementById ("Error_box") var oupass= document.getElementById ("UPass")        if(ouname.value.length<6) {oerror.innerhtml="user name is at least 6 bits"        }        if(ouname.value.length>20) {oerror.innerhtml="user name must not exceed 20 digits"        }        if(ouname.value.length>6&ouname.value.length<20&oupass.value.length<6) {oerror.innerhtml="password is at least 6 bits"        }        if(ouname.value.length>6&ouname.value.length<20&oupass.value.length>20) {oerror.innerhtml="password must not exceed 20 digits"        }    }    </script>class="Flex-container"> <divclass="Box"> <div id="Container"style="width:400px"> <div id="Header"style="Background-color:pink"&GT;&LT;H2 align="Center"style="margin-bottom:0;">Login"content"style="Background-color:hotpink;height:150px;width:400px;float:left;"align="Center"> <divclass="Input_box">username:<input id='uname'Type="text"Placeholder="Please input username"></div> <divclass="Input_box">password:<input id='UPass'Type="Password"Placeholder="Please input password"></div><br> <div id="Error_box"><br></div> <divclass="Input_box"> <divclass="Input_box"><button onclick="Fnlogin ()">login</button> <button Onclick=window.alert ("Cancel will not save changes") >cancle</button></div> <div id="Footer"style="Background-color:pink;clear:both;text-align:center;"> duym</div> </div> <br> </div></div></body>

JavaScript Basics, Login front-end verification

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.