javascript - A mix between and , or wrapping the -



javascript - A mix between <input> and <textarea>, or wrapping the <input> -

hi need user edit little text, similar "tweet", 100 characters, unlike actual twitter tweets, new line character not allowed, single line. thing edit field must short horizontally, much less text length, 20-40 characters wide. textarea much more convenient 2 or 3 rows.

so need mix between textarea , input line. or in other words input line not scrolling wrapping. wrap long strings two-three lines, not allow new line characters. how accomplish this?

this kind of input needed 2 reasons, 1 width of parent element fixed when on pc browser, , sec used in phone browser (320 pixels wide).

the short reply utilize textarea , utilize javascript filter input, , css prepare box dimensions.

something this:

class="lang-html prettyprint-override"><textarea id="message"></textarea>

the javascript monitor key pressed, , allow character if it’s not line feed , if total length less maximum.

class="lang-js prettyprint-override">window.addeventlistener('load',init,false); function init() { var message=document.getelementbyid('message'); message.onkeypress=checkmessage; } function checkmessage(event) { event=event||window.event; var key=event.which; var max=60; homecoming key.code!=13 && this.value.length<max; }

javascript html css forms textarea

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -