From jQuery JavaScript Library
« Back to Plugins/Validation
:blank
Matches elements with a blank value
Blank means either no value at all or only whitespace.
The implementation does a check like this: jQuery.trim(value).length == 0
Examples:| Name | Type |
Finds input elements with no value or just whitespace.
$("input:blank").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:blank").css("background-color", "#bbbbff");
});
</script>
</head>
<body>
<input value=""/><input value=" "/><input value="abc"/>
</body>
</html>