Three ways to use 1.<script></script>:
A, put in <body>
B. Put in
C. Put in an external JS file
2. Three ways of outputting data:
A. Use the document.write () method to write content to an HTML document.
B. Use the Window.alert () pop-up warning box.
C. Write to the HTML element using InnerHTML.
1. Use the id attribute 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>Time</title> <Scripttype= "Text/javascript"src=".. /static/js2.js "></Script></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>
3. The login page prepares:
A. Add the error prompt box.
B. Write a good html+css file.
C. Setting the ID of each INPUT element
4. Define JavaScript functions.
A. Verify user name 6-20-bit
B. Verify password 6-20-bit
C.onclick calls this function.
<!DOCTYPE HTML><HTMLLang= "en"><Head> <Bodybgcolor= "#f5deb3"> <MetaCharSet= "UTF-8"> <title>Game Login</title> <Linkhref=".. /static/css/text.css "rel= "stylesheet"type= "Text/css"> <Script> functionMyLogin () {varOuname=document.getElementById ("uname"); varOerror=document.getElementById ("Error_box"); if(OUname.value.length<6||OUname.value.length> -) {oerror.innerhtml="username must be greater than 5 bits or less than 20 bits! " } } </Script></Head><Body><Divclass= "Y45"> <H1>VIP Player Login</H1> <Divclass= "Input_y45"> <inputID= "Uname"type= "text"placeholder= "Please enter user name"> </Div> <Divclass= "Input_y45"> <inputID= "UPass"type= "Password"placeholder= "Please enter password"> </Div> <DivID= "Error_y45"><BR></Div> <Divclass= "Input_y45"> <Buttononclick= "MyLogin ()">Login</Button> </Div> </Div></Body></Body>
Div{margin:0 Auto;text-align:Center;Background-color:#f0c5df;}. input_y45{width:300px;Height:30px;Border-bottom-color:Coral;Border-bottom-style:Groove;Border-bottom-width:2px;Line-height:30px;Font-weight:Bold;Background-color:Seashell;}. input_y45{font-size:8px;Font-weight:Bold;Border-color:#85d6ff;}. error_y45{width:300px;Height:30px;Border-bottom-color:#85d6ff;Border-bottom-style:Groove;Border-bottom-width:2px;Line-height:30px;Font-weight:Bold;Background-color:#ffbaa2;}
JavaScript Basics, Login front-end verification