finding all empty text fields with jQuery
Needed to do a basic validation check for a client which simply told the user that not all the fields have been completed are they sure they want to continue. Turns out jQuery made this simples with the command $(":text[value=]") which returns all the objects. In the end my (cut down) function that I used on submit of the form was:
ColdFISH is developed by Jason Delmore. Source code and license information available at coldfish.riaforge.org
function emptyFieldCount(){
var fieldCnt = $(":text[value=]");
var isOk = true;
if(fieldCnt.length > 10){
isOk = confirm('Are you sure you want to continue, not all fields have been filled out');
}
return isOk;
}
1function emptyFieldCount(){
2 var fieldCnt = $(":text[value=]");
3 var isOk = true;
4 if(fieldCnt.length > 10)
{5 isOk = confirm('Are you sure you want to continue, not all fields have been filled out');
6 }7 return isOk;
8}