<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>JavaScript</title> </head> <body> <p id="demo">time</p> <script> document.write(Date()).innerHTML = aaabbbaa; document.getElementById("demo").innerHTML = 123456789; </script> <button type="button" onclick=window.alert("number")>press</button> </body> </html>
<!doctype html> <html lang="em"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>登录</title> <link rel="stylesheet" type="text/css" href="../static/css/styles.css"> <script> function fnLogin() { var oUname = document.getElementById("uname") var oError = document.getElementById("error_box") var oUpass = document.getElementById("upass") if(oUname.value.length<6 ){ oError.innerHTML="用户名至少6位" } if(oUname.value.length >12){ oError.innerHTML="用户名最多12位" } if(oUpass.value.length<6){ oError.innerHTML="密码至少6位" } if(oUpass.value.length>12){ oError.innerHTML="密码最多12位" } } </script> </head> <body class="body"> <div class="box"> <h2 class="ziti">登录</h2> <div class="input_box"> <input id="uname" type="text" placeholder="请输入用户名"> </div><br> <div class="input_box"> <input id="upass" type="password" placeholder="请输入密码"> </div> <div id="error_box"><br></div> <div class="input_box"> <button onclick="fnLogin()">登录</button> </div> </div> </body> </html>