Check value length from textarea - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Check value length from textarea

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 substitute(argument) {//from  w ww .j  a  v  a2 s  . c o  m
    var myVal=document.getElementById('myTextBox').value;
    if (myVal.length>0) {
       console.log(myVal);
    }
    if (myVal.length==0) {
        console.log('Empty Textbox');
    }
}

      </script> 
   </head> 
   <body> 
      <input type="button" name="Button" value="Click Me" onclick="substitute();"> 
      <textarea name="myTextBox" id="myTextBox"></textarea>  
   </body>
</html>

Related Tutorials