:filled Selector

filled selector

Description: Selects all elements with a filled value.

  • jQuery( ":filled" )

filled means any value, but not only whitespace.

The implementation does a check like this: jQuery.trim(value).length > 0

Example:

Finds input elements with a non-whitespace value.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Finds input elements with a non-whitespace value.</title>
<link rel="stylesheet" href="https://jqueryvalidation.org/files/demo/site-demos.css">
</head>
<body>
<form id="myform">
<div>Mouseover to see the value of each input</div>
<input value="" title='""'>
<input value=" " title='" "'>
<input value="abc" title='"abc"'>
</form>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/jquery.validate.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.validation/1.16.0/additional-methods.min.js"></script>
<script>
// just for the demos, avoids form submit
jQuery.validator.setDefaults({
debug: true,
success: "valid"
});
$( "input:filled" ).css( "background-color", "#bbbbff" );
</script>
</body>
</html>

Demo: