Detect a string typed in textarea via its onkeyup event - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Detect a string typed in textarea via its onkeyup event

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
var oldText = '';
function checkText(text)//from  w w  w . j  a  va2 s  . c  o  m
{
    if(text.length >= 1)
    {
        if(text == '<svg>' && text != oldText)
        {
            console.log("<svg> found");
        }
    }
    oldText = text;
}

      </script> 
   </head>
   <body> 
      <textarea onkeyup="checkText(this.value);"></textarea>  
   </body>
</html>

Related Tutorials