how do i validate dynamic textboxes which are generated at runtime using jQuery?
-
What do you want to validate?MrHus– MrHus2009-05-04 09:09:02 +00:00Commented May 4, 2009 at 9:09
-
How you create these textboxs, client side or server?Amr Elgarhy– Amr Elgarhy2009-05-04 09:43:48 +00:00Commented May 4, 2009 at 9:43
-
the textboxes are created dynamically on server-side.input– input2009-05-04 09:53:14 +00:00Commented May 4, 2009 at 9:53
Add a comment
|
2 Answers
<%
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());
});
});
Comments
I am not sure, but you can use something like this:
$(function() {
$('input').each(function() {
$('#' + this.id).live('onchange', function() {
// VALIDATION Code
});
});
1 Comment
Chad Grant
live() does not support change yet :(