Skip to content

Instantly share code, notes, and snippets.

@radamant
Created August 17, 2010 22:41
Show Gist options
  • Select an option

  • Save radamant/532444 to your computer and use it in GitHub Desktop.

Select an option

Save radamant/532444 to your computer and use it in GitHub Desktop.
var rules = {"email-address":{minlength:10}}
// or var validations = { rules: {...}, messages: {...} }
for(fieldName in rules){
var element = $('input[name="' + fieldName + '"]');
var fieldRules = rules[fieldName]
for(ruleName in fieldRules){
var rule = {};
rule[ruleName] = fieldRules[ruleName];
element.rules("add", rule);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment