Is there a way to apply styling to values in textbox and textareas?

  • Profile Image
    grade4pagasa
    Asked on January 15, 2016 at 10:13 AM
    1.) Can text formatting be applied to the output stored in textboxes or text areas? 
  • Profile Image
    Ben
    Answered on January 15, 2016 at 10:24 AM

    Now, is it possible to add <b>formatting</b> to the values within textbox and textarea..yes, that is possible. Will they be shown as above as:

    formatting

    or as

    <b>formatting</b>

    - the answer would be the latter - with the HTML elements clearly shown.

    This is a limitation of the input element (textbox) and the textarea element since they are there to show the text only.

    The only way to show formatting within it would be to do the following steps:

    1. have textarea that captures the value in its raw form (the second formatting sample above)

    2. have a div or some other element right above the textarea into which you feed the data from the textarea - this would then make it show as the first formatting sample above.

    Having said this, it means that we can not apply the style to the textbox or textarea directly, but using Text field is the way to go to achieve this.

    Now I know that you are familiar with this Randy, but I still wanted to move this into a new thread to avoid having a lot of answers combined into a single long one.

    Just to add, it would unfortunately not be possible to make the input or textarea show the styles directly neither with CSS nor with JS (javascript).