In ASP.Net, I'm adding controls dynamically using jQuery.tmpl.
I'm initializing the validator in the $(document).ready() function
with $("#form1").validate();
, my dynamic controls have class="required"
, and I'm calling $("#form1").valid()
on a click event.
Static controls on the page validate, but controls added dynamically do not. What's wrong here?
Also, the dynamic controls make the validator act weird, showing and hiding the validation message as I click on different controls.
Example: http://jsfiddle.net/wY6xt/2/
The problem is that the plug-in requires controls being validated to have unique names. The controls being added here all have the same name so the plug-in is acting crazy.
Here is the example fixed to work with unique names: http://jsfiddle.net/wY6xt/3/