I have a TEXTAREA control (ID="taCode"), maxlength=400, that is pre-filled with 400 whitespaces.
I use Javascript to force insert-mode (replace) when entering text into textarea:
var input = document.getElementById("taCode");
input.addEventListener('keypress', function(){
var s = this.selectionStart;
var e = this.selectionEnd;
this.value = this.value.substr(0, s) + this.value.substr(e + 1);
if (this.value.length < 399)
{
this.value += new Array(399-this.value.length).join(' ');
}
this.selectionEnd = this.selectionStart = s;
}, false);
HTML:
<TEXTAREA ID="taCode" COLS="80" ROWS="5" MAXLENGTH="400" style="overflow:hidden"> </TEXTAREA>
Everything works fine using a desktop and mouse, but trying to place the cursor inside the TEXTAREA using a mobile (Iphone) fails (EDIT: Placing cursor on first row works sometimes) and nothing can be typed into the field, except for on the first line. Any idea of how to get it to work for mobiles for all lines?