Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Place holder for `Textarea` not working in `Bootstrap`

     <div class="form-group">
       <label for="user-message" class="col-lg-2 control-label">Message
       </label>
       <div class="col-lg-10">
           <textarea name="user-message" id="user-message" class="form-control" cols="20" rows="10" placeholder="Enter your Message">
           </textarea> 
       </div><!--end col 10-->
     </div><!--ends from group-->

I am new to Bootstrap. I was trying to use placeholder in textarea.I was not able to see the Placeholervalues in my textarea.Please help me in this.

like image 710
Akila Avatar asked Apr 28 '17 05:04

Akila


People also ask

Why textarea placeholder is not showing?

If you have an input in your form and placeholder is not showing because a white space at the beginning, this may be caused for you "value" attribute. In case you are using variables to fill the value of an input check that there are no white spaces between the commas and the variables.

Can you use placeholder in textarea?

The placeholder attribute of the <textarea> element is used to set a placeholder text in the textarea. A placeholder is considered as a hint, like “Enter you name”, “Enter mobile number”, “Write in 100 words”, etc. Above, text is the hint you want to set for the textarea as a placeholder text.

What is the use of placeholder in bootstrap?

Placeholders can be used to enhance the experience of your application. They're built only with HTML and CSS, meaning you don't need any JavaScript to create them. You will, however, need some custom JavaScript to toggle their visibility.

What is textarea in Bootstrap?

Definition A Bootstrap Textarea is an input dedicated to a large volume of text. It may be used in a variety of components like forms, comment sections, chats and forums. Textarea can hold an unlimited number of characters, and the text renders in a fixed-width font.

How do I add placeholder text to a textarea?

You can add placeholder text to a textarea by using the HTML placeholder attribute; for example: <textarea placeholder="Describe yourself here..."></textarea> If you’re building an application that requires users to enter text, you’ll most likely be taking advantage of a rich text editor like TinyMCE.

Why the placeholder is not displayed in the input area?

The opening and closing tags for the <textarea> element must be on the same line, otherwise a newline character occupies it. The placeholder will therefore not be displayed since the input area contains content which is a newline. Show activity on this post. Thanks for contributing an answer to Stack Overflow!

What is a simple textarea?

A basic example of a simple textarea input. A Bootstrap Textarea is an input dedicated to a large volume of text. It may be used in a variety of components like forms, comment sections, chats and forums. Textarea can hold an unlimited number of characters, and the text renders in a fixed-width font.


3 Answers

Placeholder text is only shown when there is no content in the input component.

The <textarea> element you have is not empty - there is whitespace between the start and ending tags.

The fix is to remove this whitespace:

 <div class="form-group">
   <label for="user-message" class="col-lg-2 control-label">Message
   </label>
   <div class="col-lg-10">
       <textarea name="user-message" id="user-message" class="form-control" cols="20" rows="10" placeholder="Enter your Message"></textarea>
   </div><!--end col 10-->
 </div><!--ends from group-->
like image 177
Michael Banzon Avatar answered Sep 28 '22 02:09

Michael Banzon


The opening and closing tags for the <textarea> element must be on the same line, otherwise a newline character occupies it. The placeholder will therefore not be displayed since the input area contains content which is a newline.

 <div class="form-group">
   <label for="user-message" class="col-lg-2 control-label">Message
   </label>
   <div class="col-lg-10">
       <textarea name="user-message" id="user-message" class="form-control" cols="20" rows="10" placeholder="Enter your Message"></textarea> 
   </div><!--end col 10-->
 </div><!--ends from group-->

JSFIDDLE

like image 29
Shubham Khatri Avatar answered Sep 28 '22 03:09

Shubham Khatri


Use this code

<div class="form-group">
       <label for="user-message" class="col-lg-2 control-label">Message
       </label>
       <div class="col-lg-10">    
<textarea name="user-message" id="user-message" cols="20"  rows="10" class="form-control" placeholder="Enter your Message"></textarea>
 </div><!--end col 10-->
     </div><!--ends from group-->
like image 31
Babasaheb Dhodad Avatar answered Sep 28 '22 03:09

Babasaheb Dhodad