1, <script></script> three ways to use:
Put in the <body>
Put in the Placed in an external JS file
2, three ways to output data:
Use the document.write () method to write content to an HTML document.
Use the Window.alert () pop-up warning box.
Writes to an HTML element using InnerHTML.
Use the ID property to identify the HTML element.
Use the document.getElementById (ID) method to access HTML elements.
Use innerHTML to get or insert element content.
3, the login page to prepare:
Add an Error prompt box.
Write a good html+css file.
Set the ID of each INPUT element
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Login</title> <Linkrel= "stylesheet"href=".. /static/css/10.24.1.css "></Head><Body> <PID= "Hello">Lalalala</P> <Script>document.write ("Hello"); document.getElementById ("Hello"). InnerHTML=Date (); </Script> <Buttontype= "button"onclick=window.alert ("number")>Press</Button></Body></HTML>
4. Define JavaScript functions.
Verify user name 6-20-bit
Verify password 6-20-bit
5, the onclick call this function.
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Login</title> <Linkrel= "stylesheet"type= "Text/css"href=".. /static/css//10.24.css "> <Script> functionmu () {varname=document.getElementById ("username") varPassword=document.getElementById ("Password") varError=document.getElementById ("Error_box") if(Name.value.length<6) {error.innerhtml="user name is 6-20-bit" } if(password.value.length) {error.innerhtml="password is 6-20-bit" } } </Script></Head><Body> <Divclass= "box"> <H2>Login</H2> <Divclass= "Input_box"> <inputID= "username"type= "text"placeholder= "Please enter user name"> </Div> <Divclass= "Input_box"> <inputID= "Password"type= "text"placeholder= "Please enter password"> </Div> <DivID= "Error_box"><BR></Div> <Div> <Buttononclick= "mu ()">Login</Button> </Div> </Div></Body></HTML>
JavaScript Basics, Login verification