javascript - TEXT INPUT BOX: how to display placeholder at the end of the typed text? -
so... have list of input boxes in form... no labels, placeholder texts.
lets have text input field email...
and value of text ruby@rails.com
i display: (email) after string...
(only when input blured, when input focused, label shouldn't there)...this know how it...
the problem is, don't know how calculate witdh of actual text inside input box, can display label right beside (another element positioned absolutely of course)
any ideas?
========================================================== edit
so, using in html markup
<input type="text" name="my_field" value="" data-fixed-placeholder="(email)" placeholder="email">
and using jquery check if data fixed-placeholder present... , display it...
so (just semantically... code not that)
$("[data-fixed-placeholder]").on("focus", function(e){ //hide fixed placeholder }).on("blur", function(e){ //show palceholder //1. check if there no text inside... don't show (the original placeholder still visible) //2. if there text, calculate how wide //3. wrap input box in div, make position relative, append div inside text fixed-placeholder //4. position text next actual text in input box });
hope helps me better.
Comments
Post a Comment