Check whether a textarea is empty - Javascript jQuery

Javascript examples for jQuery:Form Textarea

Description

Check whether a textarea is empty

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){//from ww w.j  a  va 2  s .c om
$("#run").click(function(){
   var content = document.getElementById("test").value;
   (content.length < 1) ? console.log("Has No Content"):"";
});
    });

      </script> 
 </head> 
 <body> 
  <textarea id="test"></textarea> 
  <div id="run">
    Click to Test 
  </div>  
 </body>
</html>

Related Tutorials