JavaScript Basics, Login verification

Source: Internet
Author: User

  1. Three ways to use <script></script>:
    1. Put in the <body>
      <!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Javascripttest</title></Head><Body><Scripttype= "Text/javascript">Alert ("JavaScript code placed in the body")</Script></Body></HTML>

    2. Put in the <!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Javascripttest</title> <Scripttype= "Text/javascript">Alert ("JavaScript code placed in the head")</Script></Head><Body></Body></HTML>

    3. Placed in an external JS file
      <!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Javascripttest</title>    <Scriptsrc=".. /static/js/javascript.js "></Script></Head><Body></Body></HTML>
      Alert ("JavaScript code placed in JS file")

  2. Three ways to output data:
    1. The
    2. uses the document.write () method to write the contents to an HTML document.
       <  body  >  <  script  >  document.write (Date ())  </ script  >  </ body  >  

       

    3. The
    4. uses the Window.alert () pop-up warning box.
       <  body  >  <  h3  >  Javascripttest pop-up warning box </ h3  >  <  button  Span style= "COLOR: #ff0000" >type  = "button"   onclick  =window.alert ("Your Information error")  >  login </ button  >  </ body  >  

       

    5. 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.
        <PID= "Test">Ppp</P><Script>document.getElementById ("Test"). InnerHTML="HELLO"</Script>

  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>Login</title>    <Linkrel= "stylesheet"type= "Text/css"href=".. /static/css/10.24.css ">    <Scriptsrc=".. /static/js/10.24.js "></Script></Head><Body><Divclass= "box">    <DivID= "title">LoginText</Div>    <H3>Login</H3>    <Divclass= "Input-box">Account Number:<inputID= "Uname"type= "text"placeholder= "Please enter user name">    </Div>    <Divclass= "Input-box">Password:<inputID= "UPass"type= "Password"placeholder= "Please enter password">    </Div>    <DivID= "Error-box"><BR></Div>    <Divclass= "Input-box">        <Buttononclick= "Fnlogin ()">Login</Button>        <ahref="">Register/resister</a>    </Div></Div></Body></HTML>
function Fnlogin () {var ouname = document.getElementById ("uname");         var oerror = document.getElementById ("Error-box");         var oupass = document.getElementById ("UPass");         var isoerror = true; oerror.innerhtml = "<BR>"; if (OUname.value.length<6|| OUname.value.length>20)              {oerror.innerhtml= "user name to 6-20-bit";              Isoerror = false;                Return } if (OUpass.value.length<6|| OUpass.value.length>20)                     {oerror.innerhtml= "password at least 6-20 digits";                      Isoerror = false;            Return }        }

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.