<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Landing</title> <Linkhref=".. /static/zz.css "rel= "stylesheet"type= "Text/css"> <Script> functionMyLogin () {varUName=document.getElementById ("name"); varUPass=document.getElementById ("UPass"); varUerror=document.getElementById ("Error_box"); if(UName.value.length<6) {uerror.innerhtml= "User name is at least 6 digits! " } if(UName.value.length> -) {uerror.innerhtml= "The user name can not be greater than digits! " } if(UName.value.length>=6&&UName.value.length<= -){ if(UPass.value.length<6) {uerror.innerhtml= "Password is at least 6 digits! " } if(UPass.value.length> -) {uerror.innerhtml= "The password can not be greater than digits! " } } } </Script></Head><Bodybgcolor= "#696969"> <Divclass= "box"> <H2>Login</H2> <Divclass= "Input-box" > <P>Please enter the user name</P> <inputID= "Name"type= "text"placeholder= "Name"> </Div> <Divclass= "Input_box"> <P>Please enter your password</P> <inputID= "UPass"type= "Password"placeholder= "Password"><BR> <ahref= "a">Forget password</a> </Div> <DivID= "Error_box"><BR></Div> <Divclass= "Input_box"> <Buttononclick= "MyLogin ()">Login</Button> </Div> </Div></Body></HTML>
. Box{ margin:0 auto; Text-align:Center; width:500px; height:300px; Border:2px solid #D87093; background:#FFC0CB; }
Three ways to use <script></script>:
-
- Put in the <body>
- Put in the
- Placed in an external JS file
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.
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Time</title></Head><Bodystyle= "Text-align:center;bgcolor:pink"> <Divstyle= "border:1px dashed #696969; width:600px;margin:0 Auto"> <h4>Current time</h4> <PID= "Demo"></P> </Div> <P></P> <Script>document.write ("hello!") document.getElementById ("Demo"). InnerHTML=Date (); </Script> <P></P> <Buttontype= "button"onclick=window.alert ("The user does not exist! ")>Login</Button></Body></HTML>
JavaScript Basics, Login front-end verification