This question has been asked before, but I can't find any answers that have been given since May 2010. If one or more of these answers are still relavent, I'd be happy to delete this question.
Does jQuery have a selector that will allow me to filter by values added by .data()?
Example: (see comments)
//Set IsValid data attribute on all elements that have fired the blur event
$(".txtPayment").blur(function (e) {
if (IsCurrency($(this).val()))
$(this).data("IsValid", true);
else
$(this).data("IsValid", false);
SumPayment();
});
//Sum all payments
// I'd like to be able to select all inputs with:
// class == "txtPayment" value != "" && IsValid == true
$('.txtPayment[value!=""]').each(function ()
{
var sum = 0;
if ($(this).data("IsValid"))
{
sum += Number($(this).val());
$(this).removeClass("textError");
}
else
{
$(this).addClass("textError");
$("#spanSumPayment").addClass("textError");
}
});
Is this possible without plugins?