I'm trying to add custom validation to a dynamically created control. Can I use .attr() to set a rule for a control?
$.fn.addValidationExpression = function(field) {
if (field.ValidationExpression != null) {
$("#fld"+getFieldIdSuffix(field)).attr("validateExpression", field.ValidationExpression);
}
return this;
}
What I am trying to avoid is having to do something like this:
$("#TestForm").validate(
{
rules:
{
someControl:
{
validateExpression: true
},
someOtherControl:
{
validateExpression: true
}
}
});