Job 17--javascript Basics, login 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.

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Javascript</title></Head><Body>    <PID= "Demo">Abcccc</P>    <Script>document.write (Date ()). InnerHTML=aaaaaaaaa; document.getElementById ("Demo"). InnerHTML= 123456789; </Script>    <Buttontype= "button"onclick=window.alert ("number")>Press</Button></Body></HTML>

      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><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Login</title>    <Linkrel= "stylesheet"href= "Style.css"type= "Text/css">    <Script>        functionFnlogin () {varOuname=document.getElementById ("uname")            varOerror=document.getElementById ("Error_box")            varOuword=document.getElementById ("Uword")            if(OUname.value.length<6) {oerror.innerhtml= "user name at least 4 bits"            }            if(OUname.value.length==0) {oerror.innerhtml= "Please enter user name"            }            if(OUname.value.length> A) {oerror.innerhtml= "user name up to 13 bits"            }            if(OUword.value.length==0) {oerror.innerhtml= "Please enter your password"            }            if(OUword.value.length<6) {oerror.innerhtml= "Password at least 6 digits"            }            if(OUword.value.length> -) {oerror.innerhtml= "password up to 20 bits"            }        }    </Script></Head><Bodystyle= "Background-color:aliceblue">    <Divclass= "box" >        <H2class= "Denglu">Login</H2>        <Divclass= "Input_box">            <inputID= "Uname"type= "text"placeholder= "Please enter user name">        </Div>        <Divclass= "Input_box">            <inputID= "Uword"type= "Password"placeholder= "Please enter password">        </Div>        <DivID= "Error_box"><BR></Div>        <Divclass= "Input_box">            <Buttononclick= "Fnlogin ()">Login</Button>        </Div>    </Div></Body></HTML>  
    . Box{        border: 1px solid #cccccc;         Width: 334px;         margin: 5px;         text-align: center;    }     . Denglu{        background-color: cornflowerblue;         font-family: Chinese in italics ;         font-size: 35px;    }     . Input_box{       height: 40px;    }

Job 17--javascript Basics, login 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.