Three ways to use 1.<script></script>:
- Put in the <body>
- Put in the
- placed in an external JS file
<! DOCTYPE html>"en">"UTF-8"> <title>javascpit</title> <script>function Displaydate () {document.getElementById ("Demo"). innerhtml=Date (); } </script> <script src="Mp.js"></script>"Demo">666</p><script>document.write (Date ()); document.getElementById ("Demo"). innerhtml=Date (); function Myfuntion () {document.getElementById ("Demo"). innerhtml="hello!";}</script><button type="Button"onclick="myfuntion ()">press</button></body>Run results
2. Three ways of outputting 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>"en">" UTF-8"> <title>Login</title> document.write (Date ()) </script><button type= "button" onclick=window.alert (" user name cannot start with a number ") > Login</button></body>Run results
<! DOCTYPE html>"en">"UTF-8"> <title>Title</title>"Demo">Hello</p> <script>document.getElementById ("Demo"). innerhtml=Date (); </script><button type="Button"Onclick=window.alert ("user name cannot start with a number") >Login</button></body>3. The login page prepares:
- Add an Error prompt box.
- Write a good html+css file.
- Set the ID of each INPUT element
4. Define JavaScript functions.
- Verify user name 6-20-bit
- Verify password 6-20-bit
5.onclick calls this function.
<! DOCTYPE html>"en">"UTF-8"> <title> login </title> <link herf=".. /static/css/js23.css"Rel="Stylesh"Rel="stylesheet"Type="Text/css"> <script>function MyLogin () {var myuname= document.getElementById ("uname"); var myerror= document.getElementById ("Error_box"); if(myuname.value.length<6) {myerror.innerhtml="user name at least 6 bit! " } } </script>class="Box"> class="Input_box"> <input id="Myuname"Type="text"Placeholder="Please enter user name"> </div> <divclass="Input_box"> <input id="Myupassword"Type="Password"Placeholder="Please enter your password"> </div> <div id="Error_box"><br></div> <divclass="Input_box"> <button> login </button> </div> </div></body>17, JavaScript Foundation, login front-end verification