Textarea click the mouse to clear the default word/click the text field default content disappears/click the text box to delete the preset content

Source: Internet
Author: User

Textarea click the mouse to clear the default word/click the text field to disappear by default/click the text box to delete the preset content.

Textarea click the mouse to clear default words click Text Field default content disappears click Text Box Delete preset content

There is a default text in the message box, search bar, or email subscription bar. For example, "Enter your content". If you click here (obtain the focus in the form ), the default text will automatically disappear.

Step 1:How to add code:

<Head>

....

<SCRIPT type = "text/JavaScript">

Function cleardefault (EL) {If (El. defaultvalue = El. Value) El. value = ""}

</SCRIPT>

...

</Head>

Step 2:In the input column, add an onfocus parameter, for example:

<Input type = "text" id = "input_email_address" name = "email" value = "your email address"Onfocus = "cleardefault (this )"/>

Step 3:For text fields, the onfocus parameter is added as follows:

<Textarea name = "comment" id = "input_comment" rows = "10 ″Onfocus = "This. value =''; this. onfocus = NULL ;"> Enter your content </textarea>

The above code is not added in the

 

**************************************** ***************************************

**************************************** **************************************** ***

 

Text Box text content disappears by default display Effect

Usually, the emphasis on text boxes is ignored. As a qualified artist, the whole page cannot be partially affected. Therefore, you must pay attention to the processing of every detail to make the page more perfect.

 

If the initial value is not empty:
<Textarea onmouseover = "javascript: If (this. value = 'move to the top of the text field and enter ') {This. value = ''; this. select ();} "Wrap = Virtual> move to the top of the text field to enter </textarea>
<Input type = "text" onmouseover = "javascript: If (this. value = 'move to the top of the text field and enter ') {This. value = ''; this. select ();} "value =" Move to the top of the text field to enter ">

 

If the initial value is empty, move the mouse away from the input text. When it is moved into the input box again, it will automatically select the previous text:
<Textarea class = "input" onmouseover = "This. Focus (); this. Select ()"> </textarea>
<Input name = "input" class = input onmouseover = This. Focus (); this. Select ()>

 

Move the text into the input box to disappear and show the text in the input box.

<Input type = "text" size = "18" value = "this is the default content" onfocus = "If (value = 'this is the default content ') {value = ''}" onblur = "If (value ='') {value = 'this is the default content'} ">

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.