Hi, I have to apply an onblur function to elements of type "numAdultsField" or "numChildrenField". How do I do that? This isn't working ...
$(".numAdultsField .numChildrenField").blur(function() { var id = $(this).attr("id"); var eltPrefix = id.substring(0, id.toLowerCase().indexOf ("num")).replace(":", "\\:"); var numAdultsElt = $('#' + eltPrefix + 'NumAdults'); var numChildrenElt = $('#' + eltPrefix + 'NumChildren'); var total = 0; if (parseInt(jQuery.trim(numAdultsElt.val())) > 0) { total += parseInt(jQuery.trim(numAdultsElt.val())); } // if if (parseInt(jQuery.trim(numChildrenElt.val())) > 0) { total += parseInt(jQuery.trim(numChildrenElt.val())); } // if $('#' + eltPrefix + 'TotalInParty').val(total); }); - Dave