Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title></title>
</head>
<body>
  
  <script>
    String.prototype.trim = function() {
      return this.replace(/^\s+|\s+$/g,"");
    }
    
    function test_field(){
      if(document.getElementById("field").value.trim() == ''){
        alert("1");
          document.getElementById("field").style.display ="2";
      }else{
        alert("3");
      }
    }
  </script>
  
  <textarea id="field">a</textarea>
  <input type="button" onclick="test_field()">
</body>
</html>
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers