Reputation: 7519
how do i validate dynamic textboxes which are generated at runtime using jQuery?
Upvotes: 0
Views: 1510
Reputation: 45382
<%
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());
});
});
Upvotes: 1
Reputation: 68922
I am not sure, but you can use something like this:
$(function() {
$('input').each(function() {
$('#' + this.id).live('onchange', function() {
// VALIDATION Code
});
});
Upvotes: 0