Javaweb03-html Notes (iv)

Source: Internet
Author: User
Tags html notes

1.1 Use JS to complete the registration page form prompt and check 1.1.1 requirements:

Registering the page before it is a popup dialog is not particularly friendly in the form of a check! You can display the error message after the text box. And when the cursor falls into the text box, the message prompts.
1.1.2 Analysis: 1.1.2.1 Technical Analysis:
"JS Output"

  • document.getElementById (""). Innerhtml= "HTML code";
  • document.write ("");
    "JS Event"
  • Onfocus: Get focus.
  • Onblur: Lose focus.
  • OnSubmit: At the time of submission.
    1.1.2.2 Step Analysis:
    "Step One" creates an HTML document
    Step two adds an event to the text box you want to check.
    "Step three" trigger function
    Step four writes the contents of a hint to the area of the HTML after the text box in the function.
    1.1.3 Code implementation:

    function Tips (id,content) {document.getElementById (id+ "Span"). InnerHTML = "<font color= ' red '                    > "+content+" </font> "; } function Checkform () {//To determine that the user name cannot be empty: Var Usernam                            E = document.getElementById ("username"). Value; if (username = = "") {document.getElementById ("Usernamespan"). InnerHTML = "<font color = ' Red ' > username cannot be empty!                                    </font> ";                            return false;                            } var password = document.getElementById ("password"). Value; if (password = = "") {document.getElementById ("Passwordspan"). InnerHTML = "<font color = ' Red ' > Password cannot be empty!                                    </font> ";                            return false; }}1.1.4 Summary: Summary of the events of 1.1.4.1 JS:
  • OnLoad:
  • OnClick:
  • OnSubmit:
  • Onfocus:
  • Onblur:
  • OnChange: The drop-down list changes the event.
  • OnDblClick: Double-click an element's event.
    Keyboard Manipulation Events:
  • OnKeyDown:
  • OnKeyUp:
  • onkeypress
    Mouse Action Events:
  • OnMouseMove
  • onmouseout:
  • onmouseover
  • OnMouseDown
  • OnMouseUp

Javaweb03-html Notes (iv)

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.