JavaScript Basics, Login front-end verification

Source: Internet
Author: User

    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><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Title</title></Head><Body>    <P>Hello</P>    <Script>document.write (Date ())</Script><Buttontype= "button"onclick=window.alert ("User name cannot start with a number")>Login</Button></Body></HTML>

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Login</title>    <Linkrel= "stylesheet"type= "Text/css"href=".. /static/css/1111.css ">    <Script>         functionMyLogin () {varOuname=document.getElementById ("name")        varOerror=document.getElementById ("Error_box")        varOpassword=document.getElementById ("Password")         if(OUname.value.length<6||OUname.value.length> -) {Oerror.innertext="user name must be 6-20-bit"; return; }            Else if(Opassword.value.length<6||Opassword.value.length> -) {Oerror.innertext="Password must be 6-20-bit"; return; }            Else{oerror.innerhtml=""; }             }    </Script></Head><Body><Divclass= "AA" >    <Divclass= "Login" ><H2>Login</H2></Div>    <Divclass= "Aa1" >Name:<inputID= "Name"type= "text"placeholder= "Please enter user name"><BR>Password:<inputID= "Password"type= "Password"placeholder= "Please enter password"><BR>        </Div>        <DivID= "Error_box"><BR></Div>      <Divclass= "Aa2" >         <Buttononclick= "MyLogin ()">Login</Button>         <Buttontype= "button"onclick=window.alert ("Whether to cancel login! ")>Cancel</Button>    </Div></Body></HTML>


Div{margin:0 Auto;text-align:Center;Backgroup-color:Gray;}. AA{width:350px;Height:200px;Background-color:Black;Margin-top:100px;}. Login{font-size:25px;Color:Cyan;}. Aa1{font-size:16px;Font-weight:Bold;Color:Cyan; }. Aa2{width:100px;Height:30px;Boder-style:Hidden;}. Design{font-size:10px;Color:Cyan;}#error_box{Color:Cyan;}

JavaScript Basics, Login front-end 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: 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.