jQuery: The Write Less, Do More JavaScript Library

Plugins/Validation/filled

From jQuery JavaScript Library

Jump to: navigation, search

« Back to Plugins/Validation

:filled

Matches elements with a value.
filled means any value, but not only whitespace. The implementation does a check like this: jQuery.trim(value).length > 0

Examples:
Finds input elements with no value or just whitespace.

$("input:filled").css("background-color", "#bbbbff");

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  <script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script>
  <script>
  $(document).ready(function(){
    $("input:filled").css("background-color", "#bbbbff");
  });
  </script>
  
</head>
<body>
  <input value=""/><input value="   "/><input value="abc"/>
</body>
</html>

NameType