3

Is it possible to place the HTML5 placeholder on the bottom of a textarea, and have it so when the user types, it goes to the bottom line, then pressing enter will push the text up?

I'll explain a little better. What I would like, is to have a 5 row textarea, and instead of starting at the top of the box, and text moving down as they enter new lines, I want it start at the bottom, and move up as they enter new lines.

If not, guess I will just need to use a background image and make it blank onkeyup

cantsay
  • 1,967
  • 3
  • 21
  • 34
  • What browsers does the solution need to support – Cody Guldner May 31 '13 at 00:15
  • if it's just possible with some, that's fine as I can just have it look different for browsers which don't support it. it actually looks fine now, but would look better if I could get this right – cantsay May 31 '13 at 11:47
  • What are you making that you need this functionality – Cody Guldner May 31 '13 at 11:50
  • The HTML5 placeholder text will disappear as soon as someone enters a character into the textfield/textarea, so you're not going to achieve this with that specific attribute. Enter JavaScript! – Marijke Luttekes May 31 '13 at 12:02

1 Answers1

-2

This has been asked before.

Here's the code from the answer to that thread (uses jquery):

if (browserIsIE) {
    var range= element.createTextRange();
    range.collapse(false);
    range.select();
} else {
    element.focus();
    var v= element.value();
    element.value= '';
    element.value= v;
}

As you can see IE needs some special treatment to function properly. That said, the basic logic of this script is to focus on a certain textbox, pull out it's value and place it back in. This then moves your flashing cursor to the end of whatever is already in the text box.

Community
  • 1
  • 1
Porschiey
  • 1,981
  • 2
  • 17
  • 25
  • 1
    thanks, my question is a little different though. what I want, is to have a 5 row textarea, and instead of starting at the top of the box, and text moving down as they enter new lines, I want it start at the bottom, and move up as they enter new lines – cantsay May 31 '13 at 11:46
  • These are two different questions – Cody Guldner May 31 '13 at 11:50