Using a string as reference to object

Zoloft

New Member
I want to pass as an object few options to my jQuery plugin.This is how I do it:\[code\]$("#contact-form").formValidate({ contactname: { "minLength": 5 }, contactemail : { "minLength": 4 }, contactsubject : { "minLength": 10 }, contactmessage : { "minLength": 25 }});\[/code\]In my function I want to refer to object with string which is input id of form field.\[code\]$.fn.formValidate = function(options) { //... var $this = $(this); var id = $this.attr("id"); var length = options.id.minLength; //...}\[/code\]This solution doesn't work.
 
Back
Top