How can I create a text input field

How can I create an input text box that takes the characters entered and displays it elsewhere, character by type as typical type?

0


source to share


2 answers


Something like that:



<input type="text" id="textField" />
<br />
<span id="textOutput"></span>

<script type="text/javascript">

    var input = document.getElementById("textField");
    var output = document.getElementById("textOutput");

    // sorry, it better to use "onkeyup" event
    // to avoid the problem described in a post below
    input.onkeyup = function(){
        output.innerText = input.value;
    };
</script>

      

+3


source


You can start by looking at the source code of the edit fields on this site. The preview refreshes as you type.



+1


source







All Articles