Homer
Homer

Reputation: 7806

jQuery Validation plug-in that works with dynamic controls

I've tried the plug-in found here, but I can't get it to work with dynamic controls.

What are some other validators that will work with dynamic controls?

Dynamic Example: http://jsfiddle.net/wY6xt/2/

Upvotes: 0

Views: 243

Answers (3)

AR.
AR.

Reputation: 1955

If you do 'inspect element' in FF you see that all new inputs do have 'error' class added if empty, but since all inputs have the same name, error message only shows once. If you call dynamic field something else it will show twice (once for static input, once for first dynamic one. Now if you have all inputs named differently (and you need that anyway) it'll work fine.

Upvotes: 2

simshaun
simshaun

Reputation: 21466

There are a couple ways you can accomplish this.

  • When adding the inputs dynamically, use the .rules() method to add the appropriate validation rules.
  • Add classes to the inputs, e.g. <input type="text" ... class="required email">

Upvotes: 1

Grooveek
Grooveek

Reputation: 10094

haven't you tried the dynamic demo ? It works very well... What are your requirements ?

Upvotes: 0

Related Questions