Checking dynamic controls with jquery

how can I check for dynamic text boxes that are generated at runtime using jQuery?

0


source to share


2 answers


<%    
        TextBox tb = new TextBox();
        tb.Attributes.Add("data-validateme","true");
        Page.Controls.Add(tb);
%>

      

Which will add HTML5 data attribute.

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

      



JQuery

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

      

+1


source


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



$(function() {
$('input').each(function() {
    $('#' + this.id).live('onchange', function() {  
        // VALIDATION Code
    });
});

      

0


source







All Articles