javascript - replacing an input field's display -


i'm trying write lightweight html/javascript widget lets me colour each character entered. thinking way have input field reacted events, actual display overlaid html div reads input field's value, highlights it, , writes out. recommended way things? there library out there implements this, , takes care of fiddly details might not have thought of?

edit: searching ways implement cronoklee's contenteditable idea brought nice article: http://perplexed.co.uk/993_contenteditable_cross_browser_wysiwyg.htm

this might of interest: http://www.w3.org/tr/html5/editing.html#contenteditable

i set contenteditable div, , call javascript function on keypress wraps last inputted character in styled span tags. if need submit inputted data, set input type='hidden' , populate on keypress. no need overlay 1 on other!

edit: realised (months later!) can use div.textcontent content of input. show text without styling no need input field catch characters.


Comments

Popular posts from this blog

how to build hyperlink for query string in php -

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

queue - mq_receive: message too long -