JavaScript Basics, Login front-end verification

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.