JavaScript gets focus and loses focus event

Source: Internet
Author: User

Improving the reuse of methods by using the method of transmitting parameters

Here's a string concatenation operation involving JavaScript

</tr> <<tr height= "40px" > <td>User name</td> <td> <font color= "Red" >*<inpu T type= "text" name= "user" size= "32px" id= "user"onfocus= "Showtips" (' User ', ' username must be filled! ' Onblur= ' checkuser (' user ', ' username cannot be null ') "/> <span id=" Userspan "&GT;&LT;/SPAN&GT;&L T;/font> </td> </tr> & Lt;tr height= "40px" > <td>Password</td> <td> <font color= "Red" >*<inpu T type= "password" name= "password" id= "password" size= "32px"onfocus= "Showtips" (' Password ', ' password must be filled! ' Onblur= ' checkuser (' password ', ' Password cannot be empty ') '/> <span id= ' Passwordspan ' >< /span></font> </td> </tr>

<script>functionshowtips (id,info) {document.getElementById (id+ "span"). innerhtml= "<font color= ' Gray ' >" +info+ "</font>"            }                        functionCheckUser (id,info) {//1. Get user-entered user name data                varUvalue=document.getElementById (ID). value; //2. Perform the validation                if(uvalue== "") {document.getElementById (id+ "span"). innerhtml= "<font color= ' Gray ' >" +info+ "</font>"                }Else{document.getElementById (id+ "span"). Innerhtml= ""                }            }        </script>

JavaScript gets focus and loses focus event

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.