views:

774

answers:

2

how do i validate dynamic textboxes which are generated at runtime using jQuery?

A: 

I am not sure, but you can use something like this:

$(function() {
$('input').each(function() {
 $('#' + this.id).live('onchange', function() {  
        // VALIDATION Code
    });
});
Amr ElGarhy
live() does not support change yet :(
Chad Grant
So i think @Deviant answer below will work
Amr ElGarhy
+1  A: 
<%    
        TextBox tb = new TextBox();
        tb.Attributes.Add("data-validateme","true");
        Page.Controls.Add(tb);
%>

Which will add an HTML5 data attribute.

<input type="text" data-validateme="true" />

jQuery:

$(document).ready(function(){
   $("*[data-validateme]").change(function(){
      alert($(this).val());
   });
});
Chad Grant