0

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

3
  • What do you want to validate? Commented May 4, 2009 at 9:09
  • How you create these textboxs, client side or server? Commented May 4, 2009 at 9:43
  • the textboxes are created dynamically on server-side. Commented May 4, 2009 at 9:53

2 Answers 2

1
<%    
        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());
   });
});
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

1 Comment

live() does not support change yet :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.