Validation Plugin

Validation Plugin

Hi,

This plugin is really terrific and has saved me tons of time!  I love the flexibility!  I'm just having one issue - any help is much appreciated!

I'm dynamically creating a table and assigning validation rules to certain cells (QuantityCells can only contain integers that are no larger than the number in another cell in the same row).  Somehow, the rules are also getting assigned to other cells in the table.  In the function where I assign dynamic rules, I use an alert to output the rules for a totally different cell.  Somehow, it has the same rules, and throws errors.  

I hope this makes sense.  Please message if anything is unclear!  

Code below.
Note: "eventbinder" is an attribute I created to make objects easier to identify.  This selector works perfectly throughout my jquery code, and in other validation instances, so I don't think the issue is with the selector.


for (idx=0; idx < data.length; idx ++)
{
//Create Table Row
table.append($('<tr>') 
.attr('id', 'tr' + data[idx].CreditId)                                                           
.append($('<td>')                   
.text(data[idx].Email)
.attr('id', idx + 'Email' )
.attr('class', 'tdText')   
)
.append($('<td>')                
.text(data[idx].UpdateDate)
.attr('class', 'tdText')   
)
.append($('<td>')                
.text(data[idx].TransactionTypeName)
.attr('class', 'tdText')   
)
.append($('<td>')                
.text(data[idx].TransactionDescriptionName)
.attr('class', 'tdText')   
)
.append($('<td>')                
.text(data[idx].CreditGroupId)
.attr('class', 'tdText')   
)
.append($('<td>')                
.text(data[idx].ProductName)
.attr('class', 'tdText')   
)
.append($('<td>')                
.text(data[idx].DeliveryMethodName)
.attr('class', 'tdText')   
)
.append($('<td>')                
.text(data[idx].BoughtQuantity)
.attr('class', 'tdText right')  
.attr('eventbinder', 'BoughtQuantityCell' + idx) 
)
.append($('<td>')                
.text(data[idx].UnitPrice)
.attr('class', 'tdText right')
.attr('eventbinder', 'PriceCell' + idx)   
)                                       
.append($('<td>')                            
.text(data[idx].UnusedQuantity)
.attr('class', 'tdText right')   
.attr('eventbinder', 'UnusedQuantityCell' + idx)   
  )
.append($('<td>')                
.attr('class', 'tdText')  
.append($('<div>')
.attr("id", "divQuantity" + idx)
.append($(document.createElement("input"))
.attr({
type:  'text'
,eventbinder: 'QuantityCell' + idx
,id: 'Quantity' + idx
,'class': 'tdText right'
 })
  )
)
)
.append($('<td>')               
.attr('class', 'tdText')   
.append($(document.createElement("input"))
.attr({
type:  'text'
,eventbinder: 'TotalCell' + idx
,id: 'Total' + idx
,'class': 'tdText right'
,readonly: 'readonly'
 })
)
)                      
);
}
//Add validation for quantity cells
$("input[eventbinder^='QuantityCell']").each(function(){
//Adding validation to ONLY QuantityCell
var invoiceRow = $(this).parent('div').parent('td').parent('tr');
var max = invoiceRow.find("td[eventbinder^='UnusedQuantityCell']").html();

$(this).rules("add", {"max": max, "integer":"true"});                 

//Alert displays rules for TotalCell: max and integer rules pop up!!!!
var rules = invoiceRow.find("input[eventbinder^='TotalCell']").rules();
for (var i in rules) 
alert(i + ":" + rules[i]);
});