Replace input text value by text in a string - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Replace input text value by text in a string

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function edValueKey(e)/*from  www  .  j av a2s. c  o  m*/
{
    var monTexte = 'This is my test';
    var my = document.getElementById("edValue").value;
    my = my.length + 1;
    document.getElementById("edValue").value = monTexte.substr(0, my);
    e.preventDefault();
}

      </script> 
   </head> 
   <body> 
      <input id="edValue" type="text" onKeyPress="edValueKey(event)">  
   </body>
</html>

Related Tutorials