Skip to content

Instantly share code, notes, and snippets.

@StevenBlack
Created January 31, 2010 21:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save StevenBlack/291241 to your computer and use it in GitHub Desktop.
jqueyt.filledin.js
/**
jQuery custom selector that filters for input elements that have values, are checked, or are selected.
Usage:
// Count the number of input items that are filled-in
$(":filledIn").length;
*/
( function( $ ){
// custom selector determines if an element is filled-in, checked, or selected.
$.expr[":"].filledIn = function( a ){
return a.type !== "hidden" &&
( a.selected ||
a.checked ||
( ( a.nodeName.toUpperCase() == "TEXTAREA" ||
(a.nodeName.toUpperCase() == "INPUT" && ( a.type=="text" || a.type=="password" ) )
)
&&
a.value !== ""
)
);
};
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment